svn commit: r297215 - head/sys/dev/extres/clk

Jared McNeill jmcneill at FreeBSD.org
Wed Mar 23 19:26:54 UTC 2016


Author: jmcneill
Date: Wed Mar 23 19:26:53 2016
New Revision: 297215
URL: https://svnweb.freebsd.org/changeset/base/297215

Log:
  Fix support for fixed factor clocks.
   - Use a different device description for fixed and fixed factor clocks.
   - Fix a bug where the "clock-div" property was stored in the "mult" field
     of the clock definition.
   - Get the fixed factor parent clock by index instead of by name, as a
     clock-names property is not required to be present here.
  
  Reviewed by:		mmel, adrian (mentor)
  Approved by:		adrian (mentor)
  Differential Revision:	https://reviews.freebsd.org/D5703

Modified:
  head/sys/dev/extres/clk/clk_fixed.c

Modified: head/sys/dev/extres/clk/clk_fixed.c
==============================================================================
--- head/sys/dev/extres/clk/clk_fixed.c	Wed Mar 23 19:24:09 2016	(r297214)
+++ head/sys/dev/extres/clk/clk_fixed.c	Wed Mar 23 19:26:53 2016	(r297215)
@@ -150,12 +150,19 @@ struct clk_fixed_softc {
 static int
 clk_fixed_probe(device_t dev)
 {
+	intptr_t clk_type;
 
-	if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) {
+	clk_type = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
+	switch (clk_type) {
+	case CLK_TYPE_FIXED:
 		device_set_desc(dev, "Fixed clock");
 		return (BUS_PROBE_DEFAULT);
+	case CLK_TYPE_FIXED_FACTOR:
+		device_set_desc(dev, "Fixed factor clock");
+		return (BUS_PROBE_DEFAULT);
+	default:
+		return (ENXIO);
 	}
-	return (ENXIO);
 }
 
 static int
@@ -184,11 +191,11 @@ clk_fixed_init_fixed_factor(struct clk_f
 	rv = OF_getencprop(node, "clock-mult", &def->mult,  sizeof(def->mult));
 	if (rv <= 0)
 		return (ENXIO);
-	rv = OF_getencprop(node, "clock-div", &def->mult,  sizeof(def->div));
+	rv = OF_getencprop(node, "clock-div", &def->div,  sizeof(def->div));
 	if (rv <= 0)
 		return (ENXIO);
 	/* Get name of parent clock */
-	rv = clk_get_by_ofw_name(sc->dev, "clocks", &parent);
+	rv = clk_get_by_ofw_index(sc->dev, 0, &parent);
 	if (rv != 0)
 		return (ENXIO);
 	def->clkdef.parent_names = malloc(sizeof(char *), M_OFWPROP, M_WAITOK);


More information about the svn-src-head mailing list