CVS commit: [netbsd-9] src/sys/dev/fdt

2019-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  8 16:56:37 UTC 2019

Modified Files:
src/sys/dev/fdt [netbsd-9]: cpufreq_dt.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #291):

sys/dev/fdt/cpufreq_dt.c: revision 1.9
sys/dev/fdt/cpufreq_dt.c: revision 1.10

Change sysctl to be named after the first CPU in the DVFS domain.
  old: machdep.cpu.frequency.*, machdep.cpufreqdt4.frequency.*
  new: machdep.cpufreq.cpu0.*, machdep.cpufreq.cpu4.*


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.2.1 src/sys/dev/fdt/cpufreq_dt.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/dev/fdt/cpufreq_dt.c
diff -u src/sys/dev/fdt/cpufreq_dt.c:1.8 src/sys/dev/fdt/cpufreq_dt.c:1.8.2.1
--- src/sys/dev/fdt/cpufreq_dt.c:1.8	Tue May 21 22:15:26 2019
+++ src/sys/dev/fdt/cpufreq_dt.c	Tue Oct  8 16:56:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufreq_dt.c,v 1.8 2019/05/21 22:15:26 jmcneill Exp $ */
+/* $NetBSD: cpufreq_dt.c,v 1.8.2.1 2019/10/08 16:56:37 martin Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.8 2019/05/21 22:15:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.8.2.1 2019/10/08 16:56:37 martin Exp $");
 
 #include 
 #include 
@@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -250,14 +251,36 @@ cpufreq_dt_sysctl_helper(SYSCTLFN_ARGS)
 	return error;
 }
 
+static struct cpu_info *
+cpufreq_dt_cpu_lookup(cpuid_t mpidr)
+{
+	CPU_INFO_ITERATOR cii;
+	struct cpu_info *ci;
+
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		if (ci->ci_cpuid == mpidr)
+			return ci;
+	}
+
+	return NULL;
+}
+
 static void
 cpufreq_dt_init_sysctl(struct cpufreq_dt_softc *sc)
 {
-	const struct sysctlnode *node, *cpunode, *freqnode;
+	const struct sysctlnode *node, *cpunode;
 	struct sysctllog *cpufreq_log = NULL;
-	const char *cpunodename;
+	struct cpu_info *ci;
+	bus_addr_t mpidr;
 	int error, i;
 
+	if (fdtbus_get_reg(sc->sc_phandle, 0, &mpidr, 0) != 0)
+		return;
+
+	ci = cpufreq_dt_cpu_lookup(mpidr);
+	if (ci == NULL)
+		return;
+
 	sc->sc_freq_available = kmem_zalloc(strlen(" ") * sc->sc_nopp, KM_SLEEP);
 	for (i = 0; i < sc->sc_nopp; i++) {
 		char buf[6];
@@ -265,28 +288,23 @@ cpufreq_dt_init_sysctl(struct cpufreq_dt
 		strcat(sc->sc_freq_available, buf);
 	}
 
-	if (device_unit(sc->sc_dev) == 0)
-		cpunodename = "cpu";
-	else
-		cpunodename = device_xname(sc->sc_dev);
-
 	error = sysctl_createv(&cpufreq_log, 0, NULL, &node,
 	CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
 	NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL);
 	if (error)
 		goto sysctl_failed;
-	error = sysctl_createv(&cpufreq_log, 0, &node, &cpunode,
-	0, CTLTYPE_NODE, cpunodename, NULL,
+	error = sysctl_createv(&cpufreq_log, 0, &node, &node,
+	0, CTLTYPE_NODE, "cpufreq", NULL,
 	NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 	if (error)
 		goto sysctl_failed;
-	error = sysctl_createv(&cpufreq_log, 0, &cpunode, &freqnode,
-	0, CTLTYPE_NODE, "frequency", NULL,
+	error = sysctl_createv(&cpufreq_log, 0, &node, &cpunode,
+	0, CTLTYPE_NODE, cpu_name(ci), NULL,
 	NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 	if (error)
 		goto sysctl_failed;
 
-	error = sysctl_createv(&cpufreq_log, 0, &freqnode, &node,
+	error = sysctl_createv(&cpufreq_log, 0, &cpunode, &node,
 	CTLFLAG_READWRITE, CTLTYPE_INT, "target", NULL,
 	cpufreq_dt_sysctl_helper, 0, (void *)sc, 0,
 	CTL_CREATE, CTL_EOL);
@@ -294,7 +312,7 @@ cpufreq_dt_init_sysctl(struct cpufreq_dt
 		goto sysctl_failed;
 	sc->sc_node_target = node->sysctl_num;
 
-	error = sysctl_createv(&cpufreq_log, 0, &freqnode, &node,
+	error = sysctl_createv(&cpufreq_log, 0, &cpunode, &node,
 	CTLFLAG_READWRITE, CTLTYPE_INT, "current", NULL,
 	cpufreq_dt_sysctl_helper, 0, (void *)sc, 0,
 	CTL_CREATE, CTL_EOL);
@@ -302,7 +320,7 @@ cpufreq_dt_init_sysctl(struct cpufreq_dt
 		goto sysctl_failed;
 	sc->sc_node_current = node->sysctl_num;
 
-	error = sysctl_createv(&cpufreq_log, 0, &freqnode, &node,
+	error = sysctl_createv(&cpufreq_log, 0, &cpunode, &node,
 	0, CTLTYPE_STRING, "available", NULL,
 	NULL, 0, sc->sc_freq_available, 0,
 	CTL_CREATE, CTL_EOL);



CVS commit: [netbsd-9] src/sys/dev/fdt

2019-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  8 16:56:37 UTC 2019

Modified Files:
src/sys/dev/fdt [netbsd-9]: cpufreq_dt.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #291):

sys/dev/fdt/cpufreq_dt.c: revision 1.9
sys/dev/fdt/cpufreq_dt.c: revision 1.10

Change sysctl to be named after the first CPU in the DVFS domain.
  old: machdep.cpu.frequency.*, machdep.cpufreqdt4.frequency.*
  new: machdep.cpufreq.cpu0.*, machdep.cpufreq.cpu4.*


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.2.1 src/sys/dev/fdt/cpufreq_dt.c

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



CVS commit: [netbsd-9] src/sys/dev/fdt

2019-09-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 28 07:22:16 UTC 2019

Modified Files:
src/sys/dev/fdt [netbsd-9]: fdt_pinctrl.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #256):

sys/dev/fdt/fdt_pinctrl.c: revision 1.9

Don't assume pinctrl-0 is the default configuration.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.4.1 src/sys/dev/fdt/fdt_pinctrl.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/dev/fdt/fdt_pinctrl.c
diff -u src/sys/dev/fdt/fdt_pinctrl.c:1.8 src/sys/dev/fdt/fdt_pinctrl.c:1.8.4.1
--- src/sys/dev/fdt/fdt_pinctrl.c:1.8	Wed Feb 27 16:56:00 2019
+++ src/sys/dev/fdt/fdt_pinctrl.c	Sat Sep 28 07:22:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_pinctrl.c,v 1.8 2019/02/27 16:56:00 jakllsch Exp $ */
+/* $NetBSD: fdt_pinctrl.c,v 1.8.4.1 2019/09/28 07:22:16 martin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_pinctrl.c,v 1.8 2019/02/27 16:56:00 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_pinctrl.c,v 1.8.4.1 2019/09/28 07:22:16 martin Exp $");
 
 #include 
 #include 
@@ -142,16 +142,16 @@ fdtbus_pinctrl_configure_node(int phandl
 		fdtbus_pinctrl_configure_node(child);
 
 		/*
-		 * Set configuration 0 for this node. This may fail if the
+		 * Set default configuration for this node. This may fail if the
 		 * pinctrl provider is missing; that's OK, we will re-configure
 		 * when that provider attaches.
 		 */
 		fdtbus_get_path(child, buf, sizeof(buf));
-		error = fdtbus_pinctrl_set_config_index(child, 0);
+		error = fdtbus_pinctrl_set_config(child, "default");
 		if (error == 0)
-			aprint_debug("pinctrl: set config pinctrl-0 for %s\n", buf);
+			aprint_debug("pinctrl: set default config for %s\n", buf);
 		else if (error != ENOENT)
-			aprint_debug("pinctrl: failed to set config pinctrl-0 for %s: %d\n", buf, error);
+			aprint_debug("pinctrl: failed to set default config for %s: %d\n", buf, error);
 	}
 }
 



CVS commit: [netbsd-9] src/sys/dev/fdt

2019-09-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 28 07:22:16 UTC 2019

Modified Files:
src/sys/dev/fdt [netbsd-9]: fdt_pinctrl.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #256):

sys/dev/fdt/fdt_pinctrl.c: revision 1.9

Don't assume pinctrl-0 is the default configuration.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.4.1 src/sys/dev/fdt/fdt_pinctrl.c

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