svn commit: r316378 - head/sys/powerpc/mpc85xx

Justin Hibbits jhibbits at FreeBSD.org
Sat Apr 1 22:29:12 UTC 2017


Author: jhibbits
Date: Sat Apr  1 22:29:11 2017
New Revision: 316378
URL: https://svnweb.freebsd.org/changeset/base/316378

Log:
  Add a helper function to get system reference clock
  
  Many devices are clocked from the SoC's platform clock / 2.  Some device nodes
  include their own clock-frequency property, while others are dependent on the
  SoC's bus-frequency property instead.  To simplify, add a helper function to get
  this clock.

Modified:
  head/sys/powerpc/mpc85xx/mpc85xx.c
  head/sys/powerpc/mpc85xx/mpc85xx.h

Modified: head/sys/powerpc/mpc85xx/mpc85xx.c
==============================================================================
--- head/sys/powerpc/mpc85xx/mpc85xx.c	Sat Apr  1 22:03:00 2017	(r316377)
+++ head/sys/powerpc/mpc85xx/mpc85xx.c	Sat Apr  1 22:29:11 2017	(r316378)
@@ -436,3 +436,18 @@ mpc85xx_fix_errata(vm_offset_t va_ccsr)
 err:
 	return;
 }
+
+uint32_t
+mpc85xx_get_system_clock(void)
+{
+	phandle_t soc;
+	uint32_t freq;
+
+	soc = OF_finddevice("/soc");
+	freq = 0;
+
+	/* freq isn't modified on error. */
+	OF_getencprop(soc, "bus-frequency", (void *)&freq, sizeof(freq));
+
+	return (freq / 2);
+}

Modified: head/sys/powerpc/mpc85xx/mpc85xx.h
==============================================================================
--- head/sys/powerpc/mpc85xx/mpc85xx.h	Sat Apr  1 22:03:00 2017	(r316377)
+++ head/sys/powerpc/mpc85xx/mpc85xx.h	Sat Apr  1 22:29:11 2017	(r316378)
@@ -171,5 +171,6 @@ void mpc85xx_enable_l3_cache(void);
 void mpc85xx_fix_errata(vm_offset_t);
 void dataloss_erratum_access(vm_offset_t, uint32_t);
 int mpc85xx_is_qoriq(void);
+uint32_t mpc85xx_get_system_clock(void);
 
 #endif /* _MPC85XX_H_ */


More information about the svn-src-all mailing list