Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Apr 2017 22:29:11 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316378 - head/sys/powerpc/mpc85xx
Message-ID:  <201704012229.v31MTBDU012688@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704012229.v31MTBDU012688>