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

2024-04-01 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Apr  1 15:52:08 UTC 2024

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

Log Message:
ti_gpio: add gpio(4) interrupt support

tested with gpiopps(4) on Beagle Bone Black


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.14 src/sys/arch/arm/ti/ti_gpio.c:1.15
--- src/sys/arch/arm/ti/ti_gpio.c:1.14	Sat Aug  7 16:18:46 2021
+++ src/sys/arch/arm/ti/ti_gpio.c	Mon Apr  1 15:52:08 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_gpio.c,v 1.14 2021/08/07 16:18:46 thorpej Exp $ */
+/* $NetBSD: ti_gpio.c,v 1.15 2024/04/01 15:52:08 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.14 2021/08/07 16:18:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.15 2024/04/01 15:52:08 jakllsch Exp $");
 
 #include 
 #include 
@@ -262,10 +262,8 @@ static struct fdtbus_gpio_controller_fun
 };
 
 static void
-ti_gpio_intr_disestablish(device_t dev, void *ih)
+ti_gpio_intr_disable(struct ti_gpio_softc * const sc, struct ti_gpio_intr * const intr)
 {
-	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;
@@ -280,6 +278,7 @@ ti_gpio_intr_disestablish(device_t dev, 
 
 	intr->intr_func = NULL;
 	intr->intr_arg = NULL;
+	intr->intr_mpsafe = false;
 }
 
 static void *
@@ -359,6 +358,15 @@ ti_gpio_intr_establish(device_t dev, u_i
 	return >sc_intr[pin];
 }
 
+static void
+ti_gpio_intr_disestablish(device_t dev, void *ih)
+{
+	struct ti_gpio_softc * const sc = device_private(dev);
+	struct ti_gpio_intr * const intr = ih;
+	
+	ti_gpio_intr_disable(sc, intr);
+}
+
 static bool
 ti_gpio_intrstr(device_t dev, u_int *specifier, char *buf, size_t buflen)
 {
@@ -423,6 +431,106 @@ ti_gpio_pin_ctl(void *priv, int pin, int
 	mutex_exit(>sc_lock);
 }
 
+static void *
+ti_gpio_gp_intr_establish(void *vsc, int pin, int ipl, int irqmode,
+int (*func)(void *), void *arg)
+{
+	struct ti_gpio_softc * const sc = vsc;
+	uint32_t val;
+
+	if (ipl != IPL_VM || pin < 0 || pin >= __arraycount(sc->sc_pins))
+		return NULL;
+
+	if (sc->sc_intr[pin].intr_func != NULL)
+		return NULL;
+
+	/*
+	 * Enabling both high and low level triggers will cause the GPIO
+	 * controller to always assert the interrupt.
+	 */
+	if ((irqmode & (GPIO_INTR_LOW_LEVEL|GPIO_INTR_HIGH_LEVEL)) ==
+	(GPIO_INTR_LOW_LEVEL|GPIO_INTR_HIGH_LEVEL))
+		return NULL;
+
+	/* Set pin as input */
+	mutex_enter(>sc_lock);
+	if (ti_gpio_ctl(sc, pin, GPIO_PIN_INPUT) != 0) {
+		mutex_exit(>sc_lock);
+		return NULL;
+	}
+
+	sc->sc_intr[pin].intr_pin = pin;
+	sc->sc_intr[pin].intr_func = func;
+	sc->sc_intr[pin].intr_arg = arg;
+	sc->sc_intr[pin].intr_mpsafe = (irqmode & GPIO_INTR_MPSAFE) != 0;
+
+	const uint32_t pin_mask = __BIT(pin);
+
+	/* Configure triggers */
+	val = RD4(sc, GPIO_LEVELDETECT0);
+	if ((irqmode & GPIO_INTR_LOW_LEVEL) != 0)
+		val |= pin_mask;
+	else
+		val &= ~pin_mask;
+	WR4(sc, GPIO_LEVELDETECT0, val);
+
+	val = RD4(sc, GPIO_LEVELDETECT1);
+	if ((irqmode & GPIO_INTR_HIGH_LEVEL) != 0)
+		val |= pin_mask;
+	else
+		val &= ~pin_mask;
+	WR4(sc, GPIO_LEVELDETECT1, val);
+
+	val = RD4(sc, GPIO_RISINGDETECT);
+	if ((irqmode & GPIO_INTR_POS_EDGE) != 0 ||
+	(irqmode & GPIO_INTR_DOUBLE_EDGE) != 0)
+		val |= pin_mask;
+	else
+		val &= ~pin_mask;
+	WR4(sc, GPIO_RISINGDETECT, val);
+
+	val = RD4(sc, GPIO_FALLINGDETECT);
+	if ((irqmode & GPIO_INTR_NEG_EDGE) != 0 ||
+	(irqmode & GPIO_INTR_DOUBLE_EDGE) != 0)
+		val |= pin_mask;
+	else
+		val &= ~pin_mask;
+	WR4(sc, GPIO_FALLINGDETECT, val);
+
+	/* Enable 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_SET, pin_mask);
+	}
+
+	mutex_exit(>sc_lock);
+	
+	return >sc_intr[pin];
+}
+
+static void
+ti_gpio_gp_intr_disestablish(void *vsc, void *ih)
+{
+	struct ti_gpio_softc * const sc = vsc;
+	struct ti_gpio_intr * const intr = ih;
+
+	ti_gpio_intr_disable(sc, intr);
+}
+
+static bool
+ti_gpio_gp_intrstr(void *vsc, int pin, int irqmode, char *buf, size_t buflen)
+{
+	struct ti_gpio_softc * const sc = vsc;
+
+	if (pin < 0 || pin >= TI_GPIO_NPINS)
+		return false;
+
+	snprintf(buf, buflen, "%s pin %d", sc->sc_modname, pin);
+	return true;
+}
+
 static void
 ti_gpio_attach_ports(struct ti_gpio_softc *sc)
 {
@@ -434,10 +542,17 @@ ti_gpio_attach_ports(struct ti_gpio_soft
 	gp->gp_pin_read = ti_gpio_pin_read;
 	gp->gp_pin_write = ti_gpio_pin_write;
 	gp->gp_pin_ctl = ti_gpio_pin_ctl;
+	gp->gp_intr_establish = ti_gpio_gp_intr_establish;
+	gp->gp_intr_disestablish = ti_gpio_gp_intr_disestablish;
+	

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

2024-04-01 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Apr  1 15:52:08 UTC 2024

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

Log Message:
ti_gpio: add gpio(4) interrupt support

tested with gpiopps(4) on Beagle Bone Black


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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

2023-09-04 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue Sep  5 02:59:07 UTC 2023

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

Log Message:
ti_com.c: set sc_type to COM_TYPE_OMAP

Avoid a kernel hang reported by Brook Milligan in PR port-arm/57598.
Patch suggested by RVP, seems correct to several of us. (If this
introduces a regression with some board, sorry, mea culpa. But in
that case we should still be carrying this, just conditionalized.)


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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

2023-09-04 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue Sep  5 02:59:07 UTC 2023

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

Log Message:
ti_com.c: set sc_type to COM_TYPE_OMAP

Avoid a kernel hang reported by Brook Milligan in PR port-arm/57598.
Patch suggested by RVP, seems correct to several of us. (If this
introduces a regression with some board, sorry, mea culpa. But in
that case we should still be carrying this, just conditionalized.)


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.11 src/sys/arch/arm/ti/ti_com.c:1.12
--- src/sys/arch/arm/ti/ti_com.c:1.11	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/ti/ti_com.c	Tue Sep  5 02:59:07 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_com.c,v 1.11 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: ti_com.c,v 1.12 2023/09/05 02:59:07 gutteridge Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.11 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.12 2023/09/05 02:59:07 gutteridge Exp $");
 
 #include 
 #include 
@@ -95,7 +95,7 @@ ti_com_attach(device_t parent, device_t 
 		return;
 	}
 
-	sc->sc_type = COM_TYPE_NORMAL;
+	sc->sc_type = COM_TYPE_OMAP;
 
 	error = bus_space_map(bst, addr, size, 0, );
 	if (error) {



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

2023-02-27 Thread Christopher KOBAYASHI
Module Name:src
Committed By:   sekiya
Date:   Mon Feb 27 21:15:09 UTC 2023

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

Log Message:
Uncomment and protect sanity checks that would drop into the debugger with a
CPSW_DEBUG_DMA define.

This handles a condition where checking for DMA_RXEOQ in the received packet
results in the console being spammed with "rxeoq" messages, which soon results
in a kernel panic.  The corresponding Debugger() call for this check was
commented out.

The TI documentation ("AM335x and AMIC110 Sitara™ Processors Technical
Reference Manual") documents the EOQ bit thus:

(14.3.2.4.1.2.4) This bit is set by the EMAC when the EMAC identifies
that a descriptor is the last for a given packet received (also sets
the EOP flag), and there are no more descriptors in the receive list
(next descriptor pointer is NULL).  The software application can use
this bit to detect when the EMAC receiver for the corresponding channel
has halted. This is useful when the application appends additional free
buffer descriptors to an active receive queue. Note that this flag is
valid on EOP descriptors only.

Moving this check (and the offending printf() ) into a debug #ifdef results in
the BeagleBone Green surviving the nightly checks; it would always drop into
the debugger before this change.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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

2023-02-27 Thread Christopher KOBAYASHI
Module Name:src
Committed By:   sekiya
Date:   Mon Feb 27 21:15:09 UTC 2023

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

Log Message:
Uncomment and protect sanity checks that would drop into the debugger with a
CPSW_DEBUG_DMA define.

This handles a condition where checking for DMA_RXEOQ in the received packet
results in the console being spammed with "rxeoq" messages, which soon results
in a kernel panic.  The corresponding Debugger() call for this check was
commented out.

The TI documentation ("AM335x and AMIC110 Sitara™ Processors Technical
Reference Manual") documents the EOQ bit thus:

(14.3.2.4.1.2.4) This bit is set by the EMAC when the EMAC identifies
that a descriptor is the last for a given packet received (also sets
the EOP flag), and there are no more descriptors in the receive list
(next descriptor pointer is NULL).  The software application can use
this bit to detect when the EMAC receiver for the corresponding channel
has halted. This is useful when the application appends additional free
buffer descriptors to an active receive queue. Note that this flag is
valid on EOP descriptors only.

Moving this check (and the offending printf() ) into a debug #ifdef results in
the BeagleBone Green surviving the nightly checks; it would always drop into
the debugger before this change.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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.16 src/sys/arch/arm/ti/if_cpsw.c:1.17
--- src/sys/arch/arm/ti/if_cpsw.c:1.16	Sun Sep 18 15:47:09 2022
+++ src/sys/arch/arm/ti/if_cpsw.c	Mon Feb 27 21:15:09 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.16 2022/09/18 15:47:09 thorpej Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.17 2023/02/27 21:15:09 sekiya Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.16 2022/09/18 15:47:09 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.17 2023/02/27 21:15:09 sekiya Exp $");
 
 #include 
 #include 
@@ -95,6 +95,8 @@ __KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 
 CTASSERT(powerof2(CPSW_NTXDESCS));
 CTASSERT(powerof2(CPSW_NRXDESCS));
 
+#undef CPSW_DEBUG_DMA	/* define this for DMA debugging */
+
 #define CPSW_PAD_LEN (ETHER_MIN_LEN - ETHER_CRC_LEN)
 
 #define TXDESC_NEXT(x) cpsw_txdesc_adjust((x), 1)
@@ -1181,10 +1183,12 @@ cpsw_rxintr(void *arg)
 			return 1;
 		}
 
+#if defined(CPSW_DEBUG_DMA)
 		if ((dw[3] & (CPDMA_BD_SOP | CPDMA_BD_EOP)) !=
 		(CPDMA_BD_SOP | CPDMA_BD_EOP)) {
-			//Debugger();
+			Debugger();
 		}
+#endif
 
 		bus_dmamap_sync(sc->sc_bdt, dm, 0, dm->dm_mapsize,
 		BUS_DMASYNC_POSTREAD);
@@ -1219,10 +1223,12 @@ next:
 		cpsw_rxdesc_paddr(sc, i));
 	}
 
+#if defined(CPSW_DEBUG_DMA)
 	if (sc->sc_rxeoq) {
 		device_printf(sc->sc_dev, "rxeoq\n");
-		//Debugger();
+		Debugger();
 	}
+#endif
 
 	cpsw_write_4(sc, CPSW_CPDMA_CPDMA_EOI_VECTOR, CPSW_INTROFF_RX);
 
@@ -1269,9 +1275,11 @@ cpsw_txintr(void *arg)
 
 		cpsw_get_txdesc(sc, sc->sc_txhead, );
 
+#if defined(CPSW_DEBUG_DMA)
 		if (dw[2] == 0) {
 			//Debugger();
 		}
+#endif
 
 		if (ISSET(dw[3], CPDMA_BD_SOP) == 0)
 			goto next;



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

2022-09-25 Thread Taylor R Campbell
> Module Name:src
> Committed By:   riastradh
> Date:   Sun Sep 25 07:50:32 UTC 2022
> 
> Modified Files:
> src/sys/arch/arm/ti: ti_fb.c ti_lcdc.c
> 
> Log Message:
> tilcdc(4): Set is_console on the drm device, not the fb child.
> 
> The drm device is represented by a rockchip,display-subsystem node in
> the device tree.  The fb child is a purely software abstraction used
> by drm.

This was supposed to read:

The drm device is represented by a ti,am33xx-tilcdc node in
the device tree.  The fb child is a purely software
abstraction used by drm.


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

2022-09-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep 25 07:50:32 UTC 2022

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

Log Message:
tilcdc(4): Set is_console on the drm device, not the fb child.

The drm device is represented by a rockchip,display-subsystem node in
the device tree.  The fb child is a purely software abstraction used
by drm.

The is_console property is used by MD firmware logic to mark which
actual device in hardware bus enumeration like PCI or FDT the system
has chosen for the console early at boot, so hanging it on the node
for the real hardware device makes more sense than hanging it on the
software abstraction, and is consistent with recent changes to drmfb
to respect its setting on other platforms for hardware devices.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_fb.c
cvs rdiff -u -r1.13 -r1.14 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_fb.c
diff -u src/sys/arch/arm/ti/ti_fb.c:1.3 src/sys/arch/arm/ti/ti_fb.c:1.4
--- src/sys/arch/arm/ti/ti_fb.c:1.3	Sun Dec 19 12:44:57 2021
+++ src/sys/arch/arm/ti/ti_fb.c	Sun Sep 25 07:50:32 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_fb.c,v 1.3 2021/12/19 12:44:57 riastradh Exp $ */
+/* $NetBSD: ti_fb.c,v 1.4 2022/09/25 07:50:32 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2019 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_wsdisplay_compat.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_fb.c,v 1.3 2021/12/19 12:44:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_fb.c,v 1.4 2022/09/25 07:50:32 riastradh Exp $");
 
 #include 
 #include 
@@ -100,13 +100,6 @@ tilcdc_fb_init(struct tilcdc_drm_task *t
 	sc_attach_task);
 	device_t self = sc->sc_dev;
 	struct tilcdcfb_attach_args * const tfa = >sc_tfa;
-
-#ifdef WSDISPLAY_MULTICONS
-	prop_dictionary_t dict = device_properties(self);
-	const bool is_console = true;
-	prop_dictionary_set_bool(dict, "is_console", is_console);
-#endif
-
 	const struct drmfb_attach_args da = {
 		.da_dev = self,
 		.da_fb_helper = tfa->tfa_fb_helper,

Index: src/sys/arch/arm/ti/ti_lcdc.c
diff -u src/sys/arch/arm/ti/ti_lcdc.c:1.13 src/sys/arch/arm/ti/ti_lcdc.c:1.14
--- src/sys/arch/arm/ti/ti_lcdc.c:1.13	Sat Jul  2 05:04:36 2022
+++ src/sys/arch/arm/ti/ti_lcdc.c	Sun Sep 25 07:50:32 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_lcdc.c,v 1.13 2022/07/02 05:04:36 skrll Exp $ */
+/* $NetBSD: ti_lcdc.c,v 1.14 2022/09/25 07:50:32 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.13 2022/07/02 05:04:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.14 2022/09/25 07:50:32 riastradh Exp $");
 
 #include 
 #include 
@@ -392,6 +392,11 @@ tilcdc_attach(device_t parent, device_t 
 		return;
 	}
 
+#ifdef WSDISPLAY_MULTICONS
+	const bool is_console = true;
+	prop_dictionary_set_bool(dict, "is_console", is_console);
+#endif
+
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
 		aprint_error(": couldn't get registers\n");
 		return;



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

2022-09-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep 25 07:50:32 UTC 2022

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

Log Message:
tilcdc(4): Set is_console on the drm device, not the fb child.

The drm device is represented by a rockchip,display-subsystem node in
the device tree.  The fb child is a purely software abstraction used
by drm.

The is_console property is used by MD firmware logic to mark which
actual device in hardware bus enumeration like PCI or FDT the system
has chosen for the console early at boot, so hanging it on the node
for the real hardware device makes more sense than hanging it on the
software abstraction, and is consistent with recent changes to drmfb
to respect its setting on other platforms for hardware devices.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_fb.c
cvs rdiff -u -r1.13 -r1.14 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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 15:47:09 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 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.15 src/sys/arch/arm/ti/if_cpsw.c:1.16
--- src/sys/arch/arm/ti/if_cpsw.c:1.15	Sun Nov  7 17:12:55 2021
+++ src/sys/arch/arm/ti/if_cpsw.c	Sun Sep 18 15:47:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.15 2021/11/07 17:12:55 jmcneill Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.16 2022/09/18 15:47:09 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.15 2021/11/07 17:12:55 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.16 2022/09/18 15:47:09 thorpej Exp $");
 
 #include 
 #include 
@@ -130,6 +130,7 @@ struct cpsw_softc {
 	volatile u_int sc_txnext;
 	volatile u_int sc_txhead;
 	volatile u_int sc_rxhead;
+	bool sc_txbusy;
 	void *sc_rxthih;
 	void *sc_rxih;
 	void *sc_txih;
@@ -622,8 +623,10 @@ cpsw_start(struct ifnet *ifp)
 	KERNHIST_FUNC(__func__);
 	CPSWHIST_CALLARGS(sc, 0, 0, 0);
 
-	if (__predict_false((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) !=
-	IFF_RUNNING)) {
+	if (__predict_false((ifp->if_flags & IFF_RUNNING) == 0)) {
+		return;
+	}
+	if (__predict_false(sc->sc_txbusy)) {
 		return;
 	}
 
@@ -655,7 +658,7 @@ cpsw_start(struct ifnet *ifp)
 		}
 
 		if (dm->dm_nsegs + 1 >= txfree) {
-			ifp->if_flags |= IFF_OACTIVE;
+			sc->sc_txbusy = true;
 			bus_dmamap_unload(sc->sc_bdt, dm);
 			break;
 		}
@@ -1033,7 +1036,7 @@ cpsw_init(struct ifnet *ifp)
 	sc->sc_txeoq = true;
 	callout_schedule(>sc_tick_ch, hz);
 	ifp->if_flags |= IFF_RUNNING;
-	ifp->if_flags &= ~IFF_OACTIVE;
+	sc->sc_txbusy = false;
 
 	return 0;
 }
@@ -1101,8 +1104,9 @@ cpsw_stop(struct ifnet *ifp, int disable
 		rdp->tx_mb[i] = NULL;
 	}
 
-	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+	ifp->if_flags &= ~IFF_RUNNING;
 	ifp->if_timer = 0;
+	sc->sc_txbusy = false;
 
 	if (!disable)
 		return;
@@ -1295,7 +1299,7 @@ cpsw_txintr(void *arg)
 
 		handled = true;
 
-		ifp->if_flags &= ~IFF_OACTIVE;
+		sc->sc_txbusy = false;
 
 next:
 		if (ISSET(dw[3], CPDMA_BD_EOP) && ISSET(dw[3], CPDMA_BD_EOQ)) {



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 15:47:09 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 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

2022-07-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul  2 05:04:36 UTC 2022

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

Log Message:
sort previous


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 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

2022-07-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul  2 05:04:36 UTC 2022

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

Log Message:
sort previous


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 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.12 src/sys/arch/arm/ti/ti_lcdc.c:1.13
--- src/sys/arch/arm/ti/ti_lcdc.c:1.12	Sat Jul  2 05:03:36 2022
+++ src/sys/arch/arm/ti/ti_lcdc.c	Sat Jul  2 05:04:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_lcdc.c,v 1.12 2022/07/02 05:03:36 skrll Exp $ */
+/* $NetBSD: ti_lcdc.c,v 1.13 2022/07/02 05:04:36 skrll Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.12 2022/07/02 05:03:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.13 2022/07/02 05:04:36 skrll Exp $");
 
 #include 
 #include 
@@ -44,8 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 



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

2022-07-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul  2 05:03:37 UTC 2022

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

Log Message:
Make this compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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

2022-07-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul  2 05:03:37 UTC 2022

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

Log Message:
Make this compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.11 src/sys/arch/arm/ti/ti_lcdc.c:1.12
--- src/sys/arch/arm/ti/ti_lcdc.c:1.11	Thu Apr 21 21:22:25 2022
+++ src/sys/arch/arm/ti/ti_lcdc.c	Sat Jul  2 05:03:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_lcdc.c,v 1.11 2022/04/21 21:22:25 andvar Exp $ */
+/* $NetBSD: ti_lcdc.c,v 1.12 2022/07/02 05:03:36 skrll Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.11 2022/04/21 21:22:25 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.12 2022/07/02 05:03:36 skrll Exp $");
 
 #include 
 #include 
@@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



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

2022-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Feb 11 23:48:33 UTC 2022

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

Log Message:
arm/ti: Omit needless dv_private assignment in omap2icu_attach.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/ti_omapintc.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_omapintc.c
diff -u src/sys/arch/arm/ti/ti_omapintc.c:1.8 src/sys/arch/arm/ti/ti_omapintc.c:1.9
--- src/sys/arch/arm/ti/ti_omapintc.c:1.8	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/ti/ti_omapintc.c	Fri Feb 11 23:48:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_omapintc.c,v 1.8 2021/01/27 03:10:20 thorpej Exp $	*/
+/*	$NetBSD: ti_omapintc.c,v 1.9 2022/02/11 23:48:33 riastradh Exp $	*/
 /*
  * Define the SDP2430 specific information and then include the generic OMAP
  * interrupt header.
@@ -29,7 +29,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_omapintc.c,v 1.8 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_omapintc.c,v 1.9 2022/02/11 23:48:33 riastradh Exp $");
 
 #include 
 #include 
@@ -260,7 +260,6 @@ omap2icu_attach(device_t parent, device_
 		INTC_WRITE(sc, n, INTC_MIR_SET, 0x);
 
 	sc->sc_dev = self;
-	self->dv_private = sc;
 
 	sc->sc_pic.pic_ops = _picops;
 	sc->sc_pic.pic_maxsources = sc->sc_nbank * 32;



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

2022-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Feb 11 23:48:33 UTC 2022

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

Log Message:
arm/ti: Omit needless dv_private assignment in omap2icu_attach.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/ti_omapintc.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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 12:44:58 UTC 2021

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

Log Message:
drm: Do the attach task dance for ti lcdc drm.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_fb.c \
src/sys/arch/arm/ti/ti_lcdc.h
cvs rdiff -u -r1.9 -r1.10 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_fb.c
diff -u src/sys/arch/arm/ti/ti_fb.c:1.2 src/sys/arch/arm/ti/ti_fb.c:1.3
--- src/sys/arch/arm/ti/ti_fb.c:1.2	Sun Dec 19 12:44:25 2021
+++ src/sys/arch/arm/ti/ti_fb.c	Sun Dec 19 12:44:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_fb.c,v 1.2 2021/12/19 12:44:25 riastradh Exp $ */
+/* $NetBSD: ti_fb.c,v 1.3 2021/12/19 12:44:57 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2019 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_wsdisplay_compat.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_fb.c,v 1.2 2021/12/19 12:44:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_fb.c,v 1.3 2021/12/19 12:44:57 riastradh Exp $");
 
 #include 
 #include 
@@ -46,6 +46,8 @@ __KERNEL_RCSID(0, "$NetBSD: ti_fb.c,v 1.
 static int	ti_fb_match(device_t, cfdata_t, void *);
 static void	ti_fb_attach(device_t, device_t, void *);
 
+static void	tilcdc_fb_init(struct tilcdc_drm_task *);
+
 static bool	ti_fb_shutdown(device_t, int);
 
 struct ti_fb_softc {
@@ -53,6 +55,7 @@ struct ti_fb_softc {
 	device_t		sc_dev;
 	struct tilcdc_framebuffer *sc_fb;
 	struct tilcdcfb_attach_args sc_tfa;
+	struct tilcdc_drm_task	sc_attach_task;
 };
 
 static paddr_t	ti_fb_mmapfb(struct drmfb_softc *, off_t, int);
@@ -78,7 +81,6 @@ ti_fb_attach(device_t parent, device_t s
 {
 	struct ti_fb_softc * const sc = device_private(self);
 	struct tilcdcfb_attach_args * const tfa = aux;
-	int error;
 
 	sc->sc_dev = self;
 	sc->sc_tfa = *tfa;
@@ -87,6 +89,18 @@ ti_fb_attach(device_t parent, device_t s
 	aprint_naive("\n");
 	aprint_normal("\n");
 
+	tilcdc_task_init(>sc_attach_task, _fb_init);
+	tilcdc_task_schedule(parent, >sc_attach_task);
+}
+
+static void
+tilcdc_fb_init(struct tilcdc_drm_task *task)
+{
+	struct ti_fb_softc *sc = container_of(task, struct ti_fb_softc,
+	sc_attach_task);
+	device_t self = sc->sc_dev;
+	struct tilcdcfb_attach_args * const tfa = >sc_tfa;
+
 #ifdef WSDISPLAY_MULTICONS
 	prop_dictionary_t dict = device_properties(self);
 	const bool is_console = true;
@@ -101,6 +115,7 @@ ti_fb_attach(device_t parent, device_t s
 		.da_fb_linebytes = tfa->tfa_fb_linebytes,
 		.da_params = _drmfb_params,
 	};
+	int error;
 
 	error = drmfb_attach(>sc_drmfb, );
 	if (error) {
Index: src/sys/arch/arm/ti/ti_lcdc.h
diff -u src/sys/arch/arm/ti/ti_lcdc.h:1.2 src/sys/arch/arm/ti/ti_lcdc.h:1.3
--- src/sys/arch/arm/ti/ti_lcdc.h:1.2	Sun Dec 19 12:44:25 2021
+++ src/sys/arch/arm/ti/ti_lcdc.h	Sun Dec 19 12:44:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_lcdc.h,v 1.2 2021/12/19 12:44:25 riastradh Exp $ */
+/* $NetBSD: ti_lcdc.h,v 1.3 2021/12/19 12:44:57 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -29,6 +29,8 @@
 #ifndef _ARM_TI_TI_LCDC_H
 #define _ARM_TI_TI_LCDC_H
 
+#include 
+
 #include 
 #include 
 #include 
@@ -74,6 +76,12 @@ struct tilcdc_softc {
 	struct clk		*sc_clk;
 	int			sc_phandle;
 
+	struct lwp			*sc_task_thread;
+	SIMPLEQ_HEAD(, tilcdc_drm_task)	sc_tasks;
+	struct workqueue		*sc_task_wq;
+
+	bool			sc_dev_registered;
+
 	struct tilcdc_crtc	sc_crtc;
 	struct tilcdc_encoder	sc_encoder;
 	struct tilcdc_vblank	sc_vbl;
@@ -99,6 +107,14 @@ struct tilcdcfb_attach_args {
 	uint32_t		tfa_fb_linebytes;
 };
 
+struct tilcdc_drm_task {
+	union {
+		SIMPLEQ_ENTRY(tilcdc_drm_task)	queue;
+		struct work			work;
+	}		tdt_u;
+	void		(*tdt_fn)(struct tilcdc_drm_task *);
+};
+
 #define tilcdc_private(ddev)		(ddev)->dev_private
 #define	to_tilcdc_framebuffer(x)	container_of(x, struct tilcdc_framebuffer, base)
 #define	to_tilcdc_crtc(x)		container_of(x, struct tilcdc_crtc, base)
@@ -108,4 +124,8 @@ struct tilcdcfb_attach_args {
 #define	WR4(sc, reg, val)		\
 	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
 
+void	tilcdc_task_init(struct tilcdc_drm_task *,
+	void (*)(struct tilcdc_drm_task *));
+void	tilcdc_task_schedule(device_t, struct tilcdc_drm_task *);
+
 #endif /* _ARM_TI_TI_LCDC_H */

Index: src/sys/arch/arm/ti/ti_lcdc.c
diff -u src/sys/arch/arm/ti/ti_lcdc.c:1.9 src/sys/arch/arm/ti/ti_lcdc.c:1.10
--- src/sys/arch/arm/ti/ti_lcdc.c:1.9	Sun Dec 19 12:44:25 2021
+++ src/sys/arch/arm/ti/ti_lcdc.c	Sun Dec 19 12:44:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_lcdc.c,v 1.9 2021/12/19 12:44:25 riastradh Exp $ */
+/* $NetBSD: ti_lcdc.c,v 1.10 2021/12/19 12:44:57 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.9 2021/12/19 12:44:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: 

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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 12:44:58 UTC 2021

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

Log Message:
drm: Do the attach task dance for ti lcdc drm.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_fb.c \
src/sys/arch/arm/ti/ti_lcdc.h
cvs rdiff -u -r1.9 -r1.10 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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 12:44:25 UTC 2021

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

Log Message:
drm: Fix arm/ti drm build.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_fb.c \
src/sys/arch/arm/ti/ti_lcdc.h
cvs rdiff -u -r1.8 -r1.9 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_fb.c
diff -u src/sys/arch/arm/ti/ti_fb.c:1.1 src/sys/arch/arm/ti/ti_fb.c:1.2
--- src/sys/arch/arm/ti/ti_fb.c:1.1	Sun Nov  3 22:59:06 2019
+++ src/sys/arch/arm/ti/ti_fb.c	Sun Dec 19 12:44:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_fb.c,v 1.1 2019/11/03 22:59:06 jmcneill Exp $ */
+/* $NetBSD: ti_fb.c,v 1.2 2021/12/19 12:44:25 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2019 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_wsdisplay_compat.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_fb.c,v 1.1 2019/11/03 22:59:06 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_fb.c,v 1.2 2021/12/19 12:44:25 riastradh Exp $");
 
 #include 
 #include 
@@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: ti_fb.c,v 1.
 #include 
 #include 
 
-#include 
+#include 
 #include 
 
 #include 
@@ -62,7 +62,6 @@ static int	ti_fb_ioctl(struct drmfb_soft
 static const struct drmfb_params tifb_drmfb_params = {
 	.dp_mmapfb = ti_fb_mmapfb,
 	.dp_ioctl = ti_fb_ioctl,
-	
 };
 
 CFATTACH_DECL_NEW(ti_fb, sizeof(struct ti_fb_softc),
Index: src/sys/arch/arm/ti/ti_lcdc.h
diff -u src/sys/arch/arm/ti/ti_lcdc.h:1.1 src/sys/arch/arm/ti/ti_lcdc.h:1.2
--- src/sys/arch/arm/ti/ti_lcdc.h:1.1	Sun Nov  3 22:59:06 2019
+++ src/sys/arch/arm/ti/ti_lcdc.h	Sun Dec 19 12:44:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_lcdc.h,v 1.1 2019/11/03 22:59:06 jmcneill Exp $ */
+/* $NetBSD: ti_lcdc.h,v 1.2 2021/12/19 12:44:25 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -29,6 +29,7 @@
 #ifndef _ARM_TI_TI_LCDC_H
 #define _ARM_TI_TI_LCDC_H
 
+#include 
 #include 
 #include 
 

Index: src/sys/arch/arm/ti/ti_lcdc.c
diff -u src/sys/arch/arm/ti/ti_lcdc.c:1.8 src/sys/arch/arm/ti/ti_lcdc.c:1.9
--- src/sys/arch/arm/ti/ti_lcdc.c:1.8	Sun Dec 19 11:01:21 2021
+++ src/sys/arch/arm/ti/ti_lcdc.c	Sun Dec 19 12:44:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_lcdc.c,v 1.8 2021/12/19 11:01:21 riastradh Exp $ */
+/* $NetBSD: ti_lcdc.c,v 1.9 2021/12/19 12:44:25 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.8 2021/12/19 11:01:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.9 2021/12/19 12:44:25 riastradh Exp $");
 
 #include 
 #include 
@@ -41,11 +41,12 @@ __KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 
 #include 
 #include 
 
-#include 
 #include 
 #include 
-#include 
+#include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -66,13 +67,11 @@ enum {
 static int	tilcdc_match(device_t, cfdata_t, void *);
 static void	tilcdc_attach(device_t, device_t, void *);
 
-static int	tilcdc_set_busid(struct drm_device *, struct drm_master *);
-
 static int	tilcdc_load(struct drm_device *, unsigned long);
-static int	tilcdc_unload(struct drm_device *);
+static void	tilcdc_unload(struct drm_device *);
 
 static struct drm_driver tilcdc_driver = {
-	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
+	.driver_features = DRIVER_MODESET | DRIVER_GEM,
 	.dev_priv_size = 0,
 	.load = tilcdc_load,
 	.unload = tilcdc_unload,
@@ -82,8 +81,6 @@ static struct drm_driver tilcdc_driver =
 	.gem_uvm_ops = _gem_cma_uvm_ops,
 
 	.dumb_create = drm_gem_cma_dumb_create,
-	.dumb_map_offset = drm_gem_cma_dumb_map_offset,
-	.dumb_destroy = drm_gem_dumb_destroy,
 
 	.name = DRIVER_NAME,
 	.desc = DRIVER_DESC,
@@ -91,8 +88,6 @@ static struct drm_driver tilcdc_driver =
 	.major = DRIVER_MAJOR,
 	.minor = DRIVER_MINOR,
 	.patchlevel = DRIVER_PATCHLEVEL,
-
-	.set_busid = tilcdc_set_busid,
 };
 
 CFATTACH_DECL_NEW(ti_lcdc, sizeof(struct tilcdc_softc),
@@ -353,8 +348,9 @@ tilcdc_ep_activate(device_t dev, struct 
 	sc->sc_encoder.base.possible_crtcs = 1 << drm_crtc_index(>sc_crtc.base);
 
 	drm_encoder_init(ddev, >sc_encoder.base, _encoder_funcs,
-	DRM_MODE_ENCODER_TMDS);
-	drm_encoder_helper_add(>sc_encoder.base, _encoder_helper_funcs);
+	DRM_MODE_ENCODER_TMDS, NULL);
+	drm_encoder_helper_add(>sc_encoder.base,
+	_encoder_helper_funcs);
 
 	return fdt_endpoint_activate(ep, activate);
 }
@@ -432,7 +428,7 @@ tilcdc_attach(device_t parent, device_t 
 
 	error = -drm_dev_register(sc->sc_ddev, 0);
 	if (error) {
-		drm_dev_unref(sc->sc_ddev);
+		drm_dev_put(sc->sc_ddev);
 		aprint_error_dev(self, "couldn't register DRM device: %d\n",
 		error);
 		return;
@@ -444,23 +440,6 @@ tilcdc_attach(device_t parent, device_t 
 }
 
 static int
-tilcdc_set_busid(struct drm_device *ddev, struct drm_master *master)
-{
-	struct tilcdc_softc * const sc = 

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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 12:44:25 UTC 2021

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

Log Message:
drm: Fix arm/ti drm build.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_fb.c \
src/sys/arch/arm/ti/ti_lcdc.h
cvs rdiff -u -r1.8 -r1.9 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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:12:55 UTC 2021

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

Log Message:
ti: cpsw: adapt to dts-5.15 bindings


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.14 src/sys/arch/arm/ti/if_cpsw.c:1.15
--- src/sys/arch/arm/ti/if_cpsw.c:1.14	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/ti/if_cpsw.c	Sun Nov  7 17:12:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.14 2021/01/27 03:10:20 thorpej Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.15 2021/11/07 17:12:55 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.14 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.15 2021/11/07 17:12:55 jmcneill Exp $");
 
 #include 
 #include 
@@ -310,6 +310,7 @@ cpsw_rxdesc_paddr(struct cpsw_softc * co
 }
 
 static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "ti,am335x-cpsw-switch" },
 	{ .compat = "ti,am335x-cpsw" },
 	{ .compat = "ti,cpsw" },
 	DEVICE_COMPAT_EOL
@@ -417,7 +418,13 @@ cpsw_attach(device_t parent, device_t se
 
 	macaddr = NULL;
 	slave = of_find_firstchild_byname(phandle, "slave");
-	if (slave > 0) {
+	if (slave == -1) {
+		slave = of_find_firstchild_byname(phandle, "ethernet-ports");
+		if (slave != -1) {
+			slave = of_find_firstchild_byname(slave, "port");
+		}
+	}
+	if (slave != -1) {
 		macaddr = fdtbus_get_prop(slave, "mac-address", );
 		if (len != ETHER_ADDR_LEN)
 			macaddr = NULL;



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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:12:55 UTC 2021

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

Log Message:
ti: cpsw: adapt to dts-5.15 bindings


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:12:45 UTC 2021

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

Log Message:
arm: ti: adapt to dts-5.15 bindings


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/ti_omaptimer.c \
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_omaptimer.c
diff -u src/sys/arch/arm/ti/ti_omaptimer.c:1.10 src/sys/arch/arm/ti/ti_omaptimer.c:1.11
--- src/sys/arch/arm/ti/ti_omaptimer.c:1.10	Thu Sep  9 12:14:37 2021
+++ src/sys/arch/arm/ti/ti_omaptimer.c	Sun Nov  7 17:12:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_omaptimer.c,v 1.10 2021/09/09 12:14:37 jakllsch Exp $	*/
+/*	$NetBSD: ti_omaptimer.c,v 1.11 2021/11/07 17:12:45 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2017 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_omaptimer.c,v 1.10 2021/09/09 12:14:37 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_omaptimer.c,v 1.11 2021/11/07 17:12:45 jmcneill Exp $");
 
 #include 
 #include 
@@ -176,7 +176,6 @@ omaptimer_attach(device_t parent, device
 	struct fdt_attach_args * const faa = aux;
 	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;
@@ -203,28 +202,24 @@ omaptimer_attach(device_t parent, device
 		return;
 	}
 
-	modname = fdtbus_get_string(phandle, "ti,hwmods");
-	if (modname == NULL)
-		modname = fdtbus_get_string(OF_parent(phandle), "ti,hwmods");
-
 	aprint_naive("\n");
-	aprint_normal(": Timer (%s)\n", modname);
+	aprint_normal(": Timer\n");
 
 	rate = clk_get_rate(hwmod);
 
-	if (strcmp(modname, "timer2") == 0) {
+	if (device_unit(self) == 1) {
 		omaptimer_enable(sc, 0);
 
 		/* Install timecounter */
 		tc->tc_get_timecount = omaptimer_get_timecount;
 		tc->tc_counter_mask = ~0u;
 		tc->tc_frequency = rate;
-		tc->tc_name = modname;
+		tc->tc_name = device_xname(self);
 		tc->tc_quality = 200;
 		tc->tc_priv = sc;
 		tc_init(tc);
 
-	} else if (strcmp(modname, "timer3") == 0) {
+	} else if (device_unit(self) == 2) {
 		const uint32_t value = (0x - ((rate / hz) - 1));
 		omaptimer_enable(sc, value);
 
Index: src/sys/arch/arm/ti/ti_sdhc.c
diff -u src/sys/arch/arm/ti/ti_sdhc.c:1.10 src/sys/arch/arm/ti/ti_sdhc.c:1.11
--- src/sys/arch/arm/ti/ti_sdhc.c:1.10	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/ti/ti_sdhc.c	Sun Nov  7 17:12:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_sdhc.c,v 1.10 2021/01/27 03:10:20 thorpej Exp $	*/
+/*	$NetBSD: ti_sdhc.c,v 1.11 2021/11/07 17:12:45 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.10 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.11 2021/11/07 17:12:45 jmcneill Exp $");
 
 #include 
 #include 
@@ -85,6 +85,10 @@ static const struct ti_sdhc_config omap4
 	.regoff = 0x100
 };
 
+static const struct ti_sdhc_config am335_sdhci_config = {
+	.regoff = 0x100
+};
+
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "ti,omap2-hsmmc",
 	  .data = _hsmmc_config },
@@ -94,6 +98,8 @@ static const struct device_compatible_en
 	  .data = _pre_es3_hsmmc_config },
 	{ .compat = "ti,omap4-hsmmc",
 	  .data = _hsmmc_config },
+	{ .compat = "ti,am335-sdhci",
+	  .data = _sdhci_config },
 
 	DEVICE_COMPAT_EOL
 };



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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:12:45 UTC 2021

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

Log Message:
arm: ti: adapt to dts-5.15 bindings


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/ti_omaptimer.c \
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

2021-09-09 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Sep  9 12:14:37 UTC 2021

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

Log Message:
Add license text I forgot to include in 1.1


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.9 src/sys/arch/arm/ti/ti_omaptimer.c:1.10
--- src/sys/arch/arm/ti/ti_omaptimer.c:1.9	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/ti/ti_omaptimer.c	Thu Sep  9 12:14:37 2021
@@ -1,7 +1,33 @@
-/*	$NetBSD: ti_omaptimer.c,v 1.9 2021/01/27 03:10:20 thorpej Exp $	*/
+/*	$NetBSD: ti_omaptimer.c,v 1.10 2021/09/09 12:14:37 jakllsch Exp $	*/
+
+/*
+ * Copyright (c) 2017 Jonathan A. Kollasch
+ * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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_omaptimer.c,v 1.9 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_omaptimer.c,v 1.10 2021/09/09 12:14:37 jakllsch Exp $");
 
 #include 
 #include 



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

2021-09-09 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Sep  9 12:14:37 UTC 2021

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

Log Message:
Add license text I forgot to include in 1.1


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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

2021-01-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jan 29 13:07:32 UTC 2021

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

Log Message:
Sort headers. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 src/sys/arch/arm/ti/ti_gpio.c:1.11
--- src/sys/arch/arm/ti/ti_gpio.c:1.10	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/ti/ti_gpio.c	Fri Jan 29 13:07:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_gpio.c,v 1.10 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: ti_gpio.c,v 1.11 2021/01/29 13:07:32 rin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -27,17 +27,17 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.10 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.11 2021/01/29 13:07:32 rin Exp $");
 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
+#include 
+#include 
 
 #include 
 #include 



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

2021-01-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jan 29 13:07:32 UTC 2021

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

Log Message:
Sort headers. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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

2021-01-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jan 27 02:12:16 UTC 2021

Modified Files:
src/sys/arch/arm/ti: ti_gpio.c ti_iic.c ti_omapintc.c ti_omaptimer.c
ti_sdhc.c

Log Message:
Use DEVICE_COMPAT_EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/ti_gpio.c \
src/sys/arch/arm/ti/ti_sdhc.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/ti_iic.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/ti_omapintc.c
cvs rdiff -u -r1.7 -r1.8 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_gpio.c
diff -u src/sys/arch/arm/ti/ti_gpio.c:1.8 src/sys/arch/arm/ti/ti_gpio.c:1.9
--- src/sys/arch/arm/ti/ti_gpio.c:1.8	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/arm/ti/ti_gpio.c	Wed Jan 27 02:12:16 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_gpio.c,v 1.8 2021/01/25 14:20:39 thorpej Exp $ */
+/* $NetBSD: ti_gpio.c,v 1.9 2021/01/27 02:12:16 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.8 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.9 2021/01/27 02:12:16 thorpej Exp $");
 
 #include 
 #include 
@@ -102,7 +102,7 @@ static const u_int ti_gpio_regmap[TI_NGP
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "ti,omap3-gpio",	.value = TI_GPIO_OMAP3 },
 	{ .compat = "ti,omap4-gpio",	.value = TI_GPIO_OMAP4 },
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 struct ti_gpio_intr {
Index: src/sys/arch/arm/ti/ti_sdhc.c
diff -u src/sys/arch/arm/ti/ti_sdhc.c:1.8 src/sys/arch/arm/ti/ti_sdhc.c:1.9
--- src/sys/arch/arm/ti/ti_sdhc.c:1.8	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/arm/ti/ti_sdhc.c	Wed Jan 27 02:12:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_sdhc.c,v 1.8 2021/01/25 14:20:39 thorpej Exp $	*/
+/*	$NetBSD: ti_sdhc.c,v 1.9 2021/01/27 02:12:16 thorpej 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.8 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.9 2021/01/27 02:12:16 thorpej Exp $");
 
 #include 
 #include 
@@ -95,7 +95,7 @@ static const struct device_compatible_en
 	{ .compat = "ti,omap4-hsmmc",
 	  .data = _hsmmc_config },
 
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 enum {

Index: src/sys/arch/arm/ti/ti_iic.c
diff -u src/sys/arch/arm/ti/ti_iic.c:1.11 src/sys/arch/arm/ti/ti_iic.c:1.12
--- src/sys/arch/arm/ti/ti_iic.c:1.11	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/arm/ti/ti_iic.c	Wed Jan 27 02:12:16 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_iic.c,v 1.11 2021/01/25 14:20:39 thorpej Exp $ */
+/* $NetBSD: ti_iic.c,v 1.12 2021/01/27 02:12:16 thorpej Exp $ */
 
 /*
  * Copyright (c) 2013 Manuel Bouyer.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.11 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.12 2021/01/27 02:12:16 thorpej Exp $");
 
 #include 
 #include 
@@ -150,7 +150,7 @@ static const struct device_compatible_en
 	/* compatible			type */
 	{ .compat = "ti,omap3-i2c",	.value = TI_IIC_OMAP3 },
 	{ .compat = "ti,omap4-i2c",	.value = TI_IIC_OMAP4 },
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 /* operation in progress */

Index: src/sys/arch/arm/ti/ti_omapintc.c
diff -u src/sys/arch/arm/ti/ti_omapintc.c:1.6 src/sys/arch/arm/ti/ti_omapintc.c:1.7
--- src/sys/arch/arm/ti/ti_omapintc.c:1.6	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/arm/ti/ti_omapintc.c	Wed Jan 27 02:12:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_omapintc.c,v 1.6 2021/01/25 14:20:39 thorpej Exp $	*/
+/*	$NetBSD: ti_omapintc.c,v 1.7 2021/01/27 02:12:16 thorpej Exp $	*/
 /*
  * Define the SDP2430 specific information and then include the generic OMAP
  * interrupt header.
@@ -29,7 +29,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_omapintc.c,v 1.6 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_omapintc.c,v 1.7 2021/01/27 02:12:16 thorpej Exp $");
 
 #include 
 #include 
@@ -61,7 +61,7 @@ static const struct device_compatible_en
 	/* compatible			number of banks */
 	{ .compat = "ti,omap3-intc",	.value = 3 },
 	{ .compat = "ti,am33xx-intc",	.value = 4 },
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 #define	INTC_READ(sc, g, o)		\

Index: src/sys/arch/arm/ti/ti_omaptimer.c
diff -u src/sys/arch/arm/ti/ti_omaptimer.c:1.7 src/sys/arch/arm/ti/ti_omaptimer.c:1.8
--- src/sys/arch/arm/ti/ti_omaptimer.c:1.7	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/arm/ti/ti_omaptimer.c	Wed Jan 27 02:12:16 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: ti_omaptimer.c,v 1.7 2021/01/25 14:20:39 thorpej Exp $	*/
+/*	$NetBSD: ti_omaptimer.c,v 1.8 2021/01/27 02:12:16 thorpej Exp $	*/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_omaptimer.c,v 1.7 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_omaptimer.c,v 1.8 2021/01/27 

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

2021-01-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jan 27 02:12:16 UTC 2021

Modified Files:
src/sys/arch/arm/ti: ti_gpio.c ti_iic.c ti_omapintc.c ti_omaptimer.c
ti_sdhc.c

Log Message:
Use DEVICE_COMPAT_EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/ti_gpio.c \
src/sys/arch/arm/ti/ti_sdhc.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/ti_iic.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/ti_omapintc.c
cvs rdiff -u -r1.7 -r1.8 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

2021-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 15 23:19:33 UTC 2021

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c ti_com.c ti_ehci.c ti_gpio.c ti_iic.c
ti_motg.c ti_omaptimer.c ti_sdhc.c

Log Message:
use fdtbus_intr_establish_xname


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/ti/if_cpsw.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/ti/ti_com.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_ehci.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/ti_gpio.c \
src/sys/arch/arm/ti/ti_sdhc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/ti_iic.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_motg.c
cvs rdiff -u -r1.4 -r1.5 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/if_cpsw.c
diff -u src/sys/arch/arm/ti/if_cpsw.c:1.12 src/sys/arch/arm/ti/if_cpsw.c:1.13
--- src/sys/arch/arm/ti/if_cpsw.c:1.12	Tue Feb  4 05:15:45 2020
+++ src/sys/arch/arm/ti/if_cpsw.c	Fri Jan 15 23:19:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.12 2020/02/04 05:15:45 thorpej Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.13 2021/01/15 23:19:33 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.12 2020/02/04 05:15:45 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.13 2021/01/15 23:19:33 jmcneill Exp $");
 
 #include 
 #include 
@@ -398,6 +398,7 @@ cpsw_attach(device_t parent, device_t se
 	bus_addr_t addr;
 	bus_size_t size;
 	int error, slave, len;
+	char xname[16];
 	u_int i;
 
 	KERNHIST_INIT(cpswhist, 4096);
@@ -462,10 +463,21 @@ cpsw_attach(device_t parent, device_t se
 		memcpy(sc->sc_enaddr, macaddr, ETHER_ADDR_LEN);
 	}
 
-	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);
+	snprintf(xname, sizeof(xname), "%s rxth", device_xname(self));
+	sc->sc_rxthih = fdtbus_intr_establish_xname(phandle, CPSW_INTROFF_RXTH,
+	IPL_VM, FDT_INTR_FLAGS, cpsw_rxthintr, sc, xname);
+
+	snprintf(xname, sizeof(xname), "%s rx", device_xname(self));
+	sc->sc_rxih = fdtbus_intr_establish_xname(phandle, CPSW_INTROFF_RX,
+	IPL_VM, FDT_INTR_FLAGS, cpsw_rxintr, sc, xname);
+
+	snprintf(xname, sizeof(xname), "%s tx", device_xname(self));
+	sc->sc_txih = fdtbus_intr_establish_xname(phandle, CPSW_INTROFF_TX,
+	IPL_VM, FDT_INTR_FLAGS, cpsw_txintr, sc, xname);
+
+	snprintf(xname, sizeof(xname), "%s misc", device_xname(self));
+	sc->sc_miscih = fdtbus_intr_establish_xname(phandle, CPSW_INTROFF_MISC,
+	IPL_VM, FDT_INTR_FLAGS, cpsw_miscintr, sc, xname);
 
 	sc->sc_bst = faa->faa_bst;
 	sc->sc_bss = size;

Index: src/sys/arch/arm/ti/ti_com.c
diff -u src/sys/arch/arm/ti/ti_com.c:1.9 src/sys/arch/arm/ti/ti_com.c:1.10
--- src/sys/arch/arm/ti/ti_com.c:1.9	Mon Sep 28 11:54:23 2020
+++ src/sys/arch/arm/ti/ti_com.c	Fri Jan 15 23:19:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_com.c,v 1.9 2020/09/28 11:54:23 jmcneill Exp $ */
+/* $NetBSD: ti_com.c,v 1.10 2021/01/15 23:19:33 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.9 2020/09/28 11:54:23 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.10 2021/01/15 23:19:33 jmcneill Exp $");
 
 #include 
 #include 
@@ -118,8 +118,8 @@ ti_com_attach(device_t parent, device_t 
 		return;
 	}
 
-	ssc->ssc_ih = fdtbus_intr_establish(phandle, 0, IPL_SERIAL,
-	FDT_INTR_MPSAFE, comintr, sc);
+	ssc->ssc_ih = fdtbus_intr_establish_xname(phandle, 0, IPL_SERIAL,
+	FDT_INTR_MPSAFE, comintr, sc, device_xname(self));
 	if (ssc->ssc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt on %s\n",
 		intrstr);

Index: src/sys/arch/arm/ti/ti_ehci.c
diff -u src/sys/arch/arm/ti/ti_ehci.c:1.1 src/sys/arch/arm/ti/ti_ehci.c:1.2
--- src/sys/arch/arm/ti/ti_ehci.c:1.1	Wed Oct 30 21:41:40 2019
+++ src/sys/arch/arm/ti/ti_ehci.c	Fri Jan 15 23:19:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_ehci.c,v 1.1 2019/10/30 21:41:40 jmcneill Exp $ */
+/* $NetBSD: ti_ehci.c,v 1.2 2021/01/15 23:19:33 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2019 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_ehci.c,v 1.1 2019/10/30 21:41:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_ehci.c,v 1.2 2021/01/15 23:19:33 jmcneill Exp $");
 
 #include 
 #include 
@@ -136,8 +136,8 @@ ti_ehci_attach(device_t parent, device_t
 		return;
 	}
 
-	ih = fdtbus_intr_establish(phandle, 0, IPL_USB, FDT_INTR_MPSAFE,
-	ehci_intr, sc);

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

2021-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 15 23:19:33 UTC 2021

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c ti_com.c ti_ehci.c ti_gpio.c ti_iic.c
ti_motg.c ti_omaptimer.c ti_sdhc.c

Log Message:
use fdtbus_intr_establish_xname


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/ti/if_cpsw.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/ti/ti_com.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_ehci.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/ti_gpio.c \
src/sys/arch/arm/ti/ti_sdhc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/ti_iic.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_motg.c
cvs rdiff -u -r1.4 -r1.5 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

2020-08-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug 16 03:48:59 UTC 2020

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

Log Message:
Initialize the i2c controller before using it.

Fixes mutex uninitialized panic in LOCKDEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.6 src/sys/arch/arm/ti/ti_iic.c:1.7
--- src/sys/arch/arm/ti/ti_iic.c:1.6	Wed Jun  3 16:00:00 2020
+++ src/sys/arch/arm/ti/ti_iic.c	Sun Aug 16 03:48:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_iic.c,v 1.6 2020/06/03 16:00:00 jmcneill Exp $ */
+/* $NetBSD: ti_iic.c,v 1.7 2020/08/16 03:48:59 riastradh Exp $ */
 
 /*
  * Copyright (c) 2013 Manuel Bouyer.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.6 2020/06/03 16:00:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.7 2020/08/16 03:48:59 riastradh Exp $");
 
 #include 
 #include 
@@ -265,6 +265,7 @@ ti_iic_attach(device_t parent, device_t 
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(>sc_mtx, MUTEX_DEFAULT, IPL_NET);
 	cv_init(>sc_cv, "tiiic");
+	iic_tag_init(>sc_ic);
 	sc->sc_ic.ic_cookie = sc;
 	sc->sc_ic.ic_acquire_bus = ti_iic_acquire_bus;
 	sc->sc_ic.ic_release_bus = ti_iic_release_bus;



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

2020-08-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug 16 03:48:59 UTC 2020

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

Log Message:
Initialize the i2c controller before using it.

Fixes mutex uninitialized panic in LOCKDEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 19:16:23 UTC 2020

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

Log Message:
PR# port-evbarm/55263: BeagleBone Black too many interrupts on CPU when
using 5V DC power cable

Handle vbus status change events, and don't busy spin in the hard intr
handler when we see a vbus error (this will always be set when VBUS is not
present).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_motg.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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 19:16:23 UTC 2020

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

Log Message:
PR# port-evbarm/55263: BeagleBone Black too many interrupts on CPU when
using 5V DC power cable

Handle vbus status change events, and don't busy spin in the hard intr
handler when we see a vbus error (this will always be set when VBUS is not
present).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_motg.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_motg.c
diff -u src/sys/arch/arm/ti/ti_motg.c:1.1 src/sys/arch/arm/ti/ti_motg.c:1.2
--- src/sys/arch/arm/ti/ti_motg.c:1.1	Sun Oct 27 16:31:26 2019
+++ src/sys/arch/arm/ti/ti_motg.c	Wed Jun  3 19:16:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_motg.c,v 1.1 2019/10/27 16:31:26 jmcneill Exp $ */
+/* $NetBSD: ti_motg.c,v 1.2 2020/06/03 19:16:23 jmcneill Exp $ */
 /*
  * Copyright (c) 2013 Manuel Bouyer.  All rights reserved.
  *
@@ -24,7 +24,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_motg.c,v 1.1 2019/10/27 16:31:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_motg.c,v 1.2 2020/06/03 19:16:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -187,8 +187,7 @@ ti_motg_intr(void *v)
 {
 	struct ti_motg_softc *sc = v;
 	uint32_t stat, stat0, stat1;
-	int rv = 0;
-	int i;
+	int rv;
 
 	MOTGHIST_FUNC(); MOTGHIST_CALLED();
 
@@ -198,34 +197,18 @@ ti_motg_intr(void *v)
 	stat1 = TIOTG_USBC_READ4(sc, USBCTRL_IRQ_STAT1);
 	DPRINTF("USB %jd 0x%jx 0x%jx stat %jd",
 	sc->sc_ctrlport, stat0, stat1, stat);
-	/* try to deal with vbus errors */
-	if (stat1 & MUSB2_MASK_IVBUSERR ) {
-		stat1 &= ~MUSB2_MASK_IVBUSERR;
-		for (i = 0; i < 1000; i++) {
-			TIOTG_USBC_WRITE4(sc, USBCTRL_IRQ_STAT1,
-			MUSB2_MASK_IVBUSERR);
-			motg_intr_vbus(>sc_motg, stat & 0x1);
-			delay(1000);
-			stat = TIOTG_USBC_READ4(sc, USBCTRL_STAT);
-			if (stat & 0x1)
-break;
-		}
-	}
+
 	if (stat0) {
 		TIOTG_USBC_WRITE4(sc, USBCTRL_IRQ_STAT0, stat0);
 	}
 	if (stat1) {
 		TIOTG_USBC_WRITE4(sc, USBCTRL_IRQ_STAT1, stat1);
 	}
-	if ((stat & 0x1) == 0) {
-		mutex_spin_exit(>sc_motg.sc_intr_lock);
-		aprint_error_dev(sc->sc_motg.sc_dev, ": vbus error\n");
-		return 1;
-	}
-	if (stat0 != 0 || stat1 != 0) {
-		rv = motg_intr(>sc_motg, ((stat0 >> 16) & 0x),
-			stat0 & 0x, stat1 & 0xff);
+	if (stat1 & USBCTRL_IRQ_STAT1_DRVVBUS) {
+		motg_intr_vbus(>sc_motg, stat & 0x1);
 	}
+	rv = motg_intr(>sc_motg, ((stat0 >> 16) & 0x),
+		stat0 & 0x, stat1 & 0xff);
 	mutex_spin_exit(>sc_motg.sc_intr_lock);
 	return rv;
 }



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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 18:26:06 UTC 2020

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

Log Message:
Fix dpll clock setting on am335x


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_dpll_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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 18:26:06 UTC 2020

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

Log Message:
Fix dpll clock setting on am335x


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_dpll_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/ti_dpll_clock.c
diff -u src/sys/arch/arm/ti/ti_dpll_clock.c:1.2 src/sys/arch/arm/ti/ti_dpll_clock.c:1.3
--- src/sys/arch/arm/ti/ti_dpll_clock.c:1.2	Tue Oct 29 22:19:13 2019
+++ src/sys/arch/arm/ti/ti_dpll_clock.c	Wed Jun  3 18:26:06 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_dpll_clock.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $ */
+/* $NetBSD: ti_dpll_clock.c,v 1.3 2020/06/03 18:26:06 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_dpll_clock.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_dpll_clock.c,v 1.3 2020/06/03 18:26:06 jmcneill Exp $");
 
 #include 
 #include 
@@ -267,7 +267,7 @@ am3_dpll_clock_set_rate(void *priv, stru
 	control |= __SHIFTIN(AM3_DPLL_EN_NM_BYPASS, AM3_DPLL_EN);
 	WR4(sc, REG_CONTROL, control);
 
-	while ((RD4(sc, REG_IDLEST) & AM3_ST_MN_BYPASS) != 0)
+	while (RD4(sc, REG_IDLEST) != AM3_ST_MN_BYPASS)
 		;
 
 	mult_div1 = __SHIFTIN(mult, DPLL_MULT);
@@ -278,7 +278,7 @@ am3_dpll_clock_set_rate(void *priv, stru
 	control |= __SHIFTIN(AM3_DPLL_EN_LOCK, AM3_DPLL_EN);
 	WR4(sc, REG_CONTROL, control);
 
-	while ((RD4(sc, REG_IDLEST) & AM3_ST_DPLL_CLK) != 0)
+	while (RD4(sc, REG_IDLEST) != AM3_ST_DPLL_CLK)
 		;
 
 	return 0;



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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 18:02:03 UTC 2020

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

Log Message:
Fix SoC revision detection. BeagleBone Black reports 1GHz as a supported
frequency again.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_cpufreq.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_cpufreq.c
diff -u src/sys/arch/arm/ti/ti_cpufreq.c:1.2 src/sys/arch/arm/ti/ti_cpufreq.c:1.3
--- src/sys/arch/arm/ti/ti_cpufreq.c:1.2	Tue Oct 29 10:54:10 2019
+++ src/sys/arch/arm/ti/ti_cpufreq.c	Wed Jun  3 18:02:03 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_cpufreq.c,v 1.2 2019/10/29 10:54:10 jmcneill Exp $ */
+/* $NetBSD: ti_cpufreq.c,v 1.3 2020/06/03 18:02:03 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_soc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_cpufreq.c,v 1.2 2019/10/29 10:54:10 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_cpufreq.c,v 1.3 2020/06/03 18:02:03 jmcneill Exp $");
 
 #include 
 #include 
@@ -62,7 +62,7 @@ am33xx_opp_supported(const int opp_table
 	int len;
 
 	syscon_lock(ti_opp_syscon);
-	rev = __SHIFTOUT(syscon_read_4(ti_opp_syscon, AM33XX_REV_OFFSET), AM33XX_REV_MASK);
+	rev = __BIT(__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);
 



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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 18:02:03 UTC 2020

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

Log Message:
Fix SoC revision detection. BeagleBone Black reports 1GHz as a supported
frequency again.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_cpufreq.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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 16:00:00 UTC 2020

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

Log Message:
If we can't find a hwmod name, use the device type and mmio address


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_gpio.c
cvs rdiff -u -r1.5 -r1.6 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_gpio.c
diff -u src/sys/arch/arm/ti/ti_gpio.c:1.3 src/sys/arch/arm/ti/ti_gpio.c:1.4
--- src/sys/arch/arm/ti/ti_gpio.c:1.3	Sun Nov  3 11:34:40 2019
+++ src/sys/arch/arm/ti/ti_gpio.c	Wed Jun  3 16:00:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_gpio.c,v 1.3 2019/11/03 11:34:40 jmcneill Exp $ */
+/* $NetBSD: ti_gpio.c,v 1.4 2020/06/03 16:00:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.3 2019/11/03 11:34:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.4 2020/06/03 16:00:00 jmcneill Exp $");
 
 #include 
 #include 
@@ -518,6 +518,8 @@ ti_gpio_attach(device_t parent, device_t
 	sc->sc_modname = fdtbus_get_string(phandle, "ti,hwmods");
 	if (sc->sc_modname == NULL)
 		sc->sc_modname = fdtbus_get_string(OF_parent(phandle), "ti,hwmods");
+	if (sc->sc_modname == NULL)
+		sc->sc_modname = kmem_asprintf("gpio@%" PRIxBUSADDR, addr);
 
 	aprint_naive("\n");
 	aprint_normal(": GPIO (%s)\n", sc->sc_modname);

Index: src/sys/arch/arm/ti/ti_iic.c
diff -u src/sys/arch/arm/ti/ti_iic.c:1.5 src/sys/arch/arm/ti/ti_iic.c:1.6
--- src/sys/arch/arm/ti/ti_iic.c:1.5	Thu May 14 08:34:20 2020
+++ src/sys/arch/arm/ti/ti_iic.c	Wed Jun  3 16:00:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_iic.c,v 1.5 2020/05/14 08:34:20 msaitoh Exp $ */
+/* $NetBSD: ti_iic.c,v 1.6 2020/06/03 16:00:00 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2013 Manuel Bouyer.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.5 2020/05/14 08:34:20 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.6 2020/06/03 16:00:00 jmcneill Exp $");
 
 #include 
 #include 
@@ -292,7 +292,11 @@ ti_iic_attach(device_t parent, device_t 
 	sc->sc_rxthres = sc->sc_txthres = fifo >> 1;
 
 	aprint_naive("\n");
-	aprint_normal(": I2C controller (%s), %d-bytes FIFO\n", modname, fifo);
+	if (modname != NULL)
+		aprint_normal(": I2C controller (%s), %d-bytes FIFO\n", modname, fifo);
+	else
+		aprint_normal(": I2C controller (i2c@%" PRIxBUSADDR "), %d-bytes FIFO\n",
+		addr, fifo);
 
 	ti_iic_reset(sc);
 	ti_iic_flush(sc);



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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 16:00:00 UTC 2020

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

Log Message:
If we can't find a hwmod name, use the device type and mmio address


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_gpio.c
cvs rdiff -u -r1.5 -r1.6 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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 15:59:22 UTC 2020

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

Log Message:
Add a line break before rnd_attach_source so the "entropy: ready" announcement 
does not get mixed with device prints


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_rng.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_rng.c
diff -u src/sys/arch/arm/ti/ti_rng.c:1.3 src/sys/arch/arm/ti/ti_rng.c:1.4
--- src/sys/arch/arm/ti/ti_rng.c:1.3	Thu Apr 30 03:40:53 2020
+++ src/sys/arch/arm/ti/ti_rng.c	Wed Jun  3 15:59:22 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_rng.c,v 1.3 2020/04/30 03:40:53 riastradh Exp $ */
+/* $NetBSD: ti_rng.c,v 1.4 2020/06/03 15:59:22 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_rng.c,v 1.3 2020/04/30 03:40:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_rng.c,v 1.4 2020/06/03 15:59:22 jmcneill Exp $");
 
 #include 
 #include 
@@ -112,12 +112,12 @@ ti_rng_attach(device_t parent, device_t 
 		TRNG_CONTROL_ENABLE);
 	}
 
+	aprint_naive("\n");
+	aprint_normal(": RNG\n");
+
 	rndsource_setcb(>sc_rndsource, ti_rng_callback, sc);
 	rnd_attach_source(>sc_rndsource, device_xname(self), RND_TYPE_RNG,
 	RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
-
-	aprint_naive("\n");
-	aprint_normal(": RNG\n");
 }
 
 static void



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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 15:59:22 UTC 2020

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

Log Message:
Add a line break before rnd_attach_source so the "entropy: ready" announcement 
does not get mixed with device prints


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_rng.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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 14:56:10 UTC 2020

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

Log Message:
Catch up to clock changes in last dts import.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_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.12 src/sys/arch/arm/ti/am3_prcm.c:1.13
--- src/sys/arch/arm/ti/am3_prcm.c:1.12	Fri Nov 29 20:54:00 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Wed Jun  3 14:56:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.13 2020/06/03 14:56:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.13 2020/06/03 14:56:09 jmcneill Exp $");
 
 #include 
 #include 
@@ -65,6 +65,11 @@ __KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v
 
 #define	DPLL_DISP_RATE29700
 
+struct am3_prcm_softc {
+	struct ti_prcm_softc	sc_prcm;	/* must be first */
+	bus_addr_t		sc_regbase;
+};
+
 static int am3_prcm_match(device_t, cfdata_t, void *);
 static void am3_prcm_attach(device_t, device_t, void *);
 
@@ -133,7 +138,17 @@ static const char * const compatible[] =
 	NULL
 };
 
-CFATTACH_DECL_NEW(am3_prcm, sizeof(struct ti_prcm_softc),
+static const char * const cm_compatible[] = {
+	"ti,omap4-cm",
+	NULL
+};
+
+static const char * const clkctrl_compatible[] = {
+	"ti,clkctrl",
+	NULL
+};
+
+CFATTACH_DECL_NEW(am3_prcm, sizeof(struct am3_prcm_softc),
 	am3_prcm_match, am3_prcm_attach, NULL, NULL);
 
 static struct ti_prcm_clk am3_prcm_clks[] = {
@@ -146,6 +161,7 @@ static struct ti_prcm_clk am3_prcm_clks[
 	TI_PRCM_FIXED_FACTOR("PERIPH_CLK", 1, 1, "FIXED_48MHZ"),
 	TI_PRCM_FIXED_FACTOR("MMC_CLK", 1, 1, "FIXED_96MHZ"),
 
+	AM3_PRCM_HWMOD_WKUP("uart0", 0xb4, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("uart1", 0x6c, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("uart2", 0x70, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("uart3", 0x74, "PERIPH_CLK"),
@@ -187,6 +203,53 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER_DISP("lcdc", 0x18, "DISPLAY_CLK"),
 };
 
+static struct clk *
+am3_prcm_clock_decode(device_t dev, int cc_phandle, const void *data, size_t len)
+{
+	struct am3_prcm_softc * const sc = device_private(dev);
+	const u_int *cells = data;
+	bus_addr_t regbase;
+	u_int n;
+
+	if (len != 8)
+		return NULL;
+
+	bus_size_t regoff = be32toh(cells[0]);
+	const u_int clock_index = be32toh(cells[1]);
+
+	/* XXX not sure how to handle this yet */
+	if (clock_index != 0)
+		return NULL;
+
+	/*
+	 * Register offset in specifier is relative to base address of the
+	 * clock node. Translate this to an address relative to the start
+	 * of PRCM space.
+	 */
+	if (fdtbus_get_reg(cc_phandle, 0, , NULL) != 0)
+		return NULL;
+	regoff += (regbase - sc->sc_regbase);
+
+	/*
+	 * Look for a matching hwmod.
+	 */
+	for (n = 0; n < sc->sc_prcm.sc_nclks; n++) {
+		struct ti_prcm_clk *tclk = >sc_prcm.sc_clks[n];
+		if (tclk->type != TI_PRCM_HWMOD)
+			continue;
+
+		if (tclk->u.hwmod.reg == regoff)
+			return >base;
+	}
+
+	/* Not found */
+	return NULL;
+}
+
+static const struct fdtbus_clock_controller_func am3_prcm_clock_fdt_funcs = {
+	.decode = am3_prcm_clock_decode
+};
+
 static int
 am3_prcm_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -198,24 +261,43 @@ am3_prcm_match(device_t parent, cfdata_t
 static void
 am3_prcm_attach(device_t parent, device_t self, void *aux)
 {
-	struct ti_prcm_softc * const sc = device_private(self);
+	struct am3_prcm_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
-	int clocks;
+	const int phandle = faa->faa_phandle;
+	int clocks, child, cm_child;
 
-	sc->sc_dev = self;
-	sc->sc_phandle = faa->faa_phandle;
-	sc->sc_bst = faa->faa_bst;
+	if (fdtbus_get_reg(phandle, 0, >sc_regbase, NULL) != 0) {
+		aprint_error(": couldn't get registers\n");
+		return;
+	}
 
-	sc->sc_clks = am3_prcm_clks;
-	sc->sc_nclks = __arraycount(am3_prcm_clks);
+	sc->sc_prcm.sc_dev = self;
+	sc->sc_prcm.sc_phandle = phandle;
+	sc->sc_prcm.sc_bst = faa->faa_bst;
+	sc->sc_prcm.sc_clks = am3_prcm_clks;
+	sc->sc_prcm.sc_nclks = __arraycount(am3_prcm_clks);
 
-	if (ti_prcm_attach(sc) != 0)
+	if (ti_prcm_attach(>sc_prcm) != 0)
 		return;
 
 	aprint_naive("\n");
 	aprint_normal(": AM3xxx PRCM\n");
 
-	clocks = of_find_firstchild_byname(sc->sc_phandle, "clocks");
+	for (child = OF_child(phandle); child; child = OF_peer(child)) {
+		if (of_match_compatible(child, cm_compatible) == 0)
+			continue;
+
+		for (cm_child =	OF_child(child); cm_child; cm_child = OF_peer(cm_child)) {
+			if (of_match_compatible(cm_child, clkctrl_compatible) == 

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

2020-06-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun  3 14:56:10 UTC 2020

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

Log Message:
Catch up to clock changes in last dts import.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_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-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.



  1   2   >