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_ */
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to