changeset 3925:9f2327b3e3fb

arch/efm32/recmu: Add support for getting node clock ratio
author Nicolas Pouillon <nipo@ssji.net>
date Tue, 08 May 2018 08:20:26 +0200
parents da601f4a2675
children 205272343b61
files arch/efm32/drivers/recmu/recmu.c
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/arch/efm32/drivers/recmu/recmu.c	Tue Apr 24 00:54:29 2018 +0200
+++ b/arch/efm32/drivers/recmu/recmu.c	Tue May 08 08:20:26 2018 +0200
@@ -357,6 +357,7 @@
 static error_t
 efm32_recmu_get_node_freq(struct efm32_recmu_private_s *pv,
                           struct dev_freq_s *freq,
+                          uint32_t *rdiv,
                           dev_cmu_node_id_t node)
 {
   uint32_t div;
@@ -475,7 +476,7 @@
   switch (node)
     {
     case EFM32_CLOCK_LE:
-      if (efm32_recmu_get_node_freq(pv, freq, EFM32_CLOCK_HFCORECLK))
+      if (efm32_recmu_get_node_freq(pv, freq, NULL, EFM32_CLOCK_HFCORECLK))
         return -EINVAL;
 # if (CONFIG_EFM32_FAMILY == EFM32_FAMILY_LEOPARD) \
   || (CONFIG_EFM32_FAMILY == EFM32_FAMILY_WONDER) \
@@ -541,6 +542,9 @@
   if (!freq->num || !freq->denom)
     return -EINVAL;
 
+  if (rdiv)
+    *rdiv = div;
+  
   if (freq->denom > 1)
     {
       uint64_t g = gcd64(freq->num, freq->denom);
@@ -1228,7 +1232,7 @@
       id += EFM32_CLOCK_FIRST_EP;
 
       struct dev_clock_notify_s notify;
-      if (efm32_recmu_get_node_freq(pv, &notify.freq, id))
+      if (efm32_recmu_get_node_freq(pv, &notify.freq, NULL, id))
         abort();
       dev_cmu_src_notify(src, &notify);
 
@@ -1287,9 +1291,15 @@
   if (node_id >= EFM32_CLOCK_count)
     return -EINVAL;
 
-  if (*mask & (DEV_CMU_INFO_FREQ | DEV_CMU_INFO_ACCURACY))
-    if (efm32_recmu_get_node_freq(pv, &info->freq, node_id))
-      *mask &= ~(DEV_CMU_INFO_FREQ | DEV_CMU_INFO_ACCURACY);
+  if (*mask & (DEV_CMU_INFO_FREQ | DEV_CMU_INFO_ACCURACY | DEV_CMU_INFO_SCALE))
+    {
+      uint32_t div = 0;
+      if (efm32_recmu_get_node_freq(pv, &info->freq, &div, node_id))
+        *mask &= ~(DEV_CMU_INFO_FREQ | DEV_CMU_INFO_ACCURACY | DEV_CMU_INFO_SCALE);
+
+      info->scale.num = 1;
+      info->scale.denom = div;
+    }
 
 #ifdef CONFIG_DRIVER_EFM32_RECMU_NAMES
   info->name = efm32_clock_names[node_id];