aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2015-08-14 06:40:09 -0400
committerThierry Reding <treding@nvidia.com>2015-10-20 07:56:54 -0400
commit4182b8d454331c5ca85b57c0a7357073d96b170f (patch)
treec11fe0a90b81c8f8c060ffb2cb73388fdb4ffb76
parent10d9be6ebe9199feb7680433a24b564a31a8f9b1 (diff)
clk: tegra: dfll: Monitor code is DEBUG_FS only
The monitor code is used with DEBUG_FS only, so move it into the corresponding #ifdef block to avoid potential compiler warnings. Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/clk/tegra/clk-dfll.c99
1 files changed, 49 insertions, 50 deletions
diff --git a/drivers/clk/tegra/clk-dfll.c b/drivers/clk/tegra/clk-dfll.c
index 6a75a7482b08..c56a5c735484 100644
--- a/drivers/clk/tegra/clk-dfll.c
+++ b/drivers/clk/tegra/clk-dfll.c
@@ -469,56 +469,6 @@ static unsigned long dfll_scale_dvco_rate(int scale_bits,
469} 469}
470 470
471/* 471/*
472 * Monitor control
473 */
474
475/**
476 * dfll_calc_monitored_rate - convert DFLL_MONITOR_DATA_VAL rate into real freq
477 * @monitor_data: value read from the DFLL_MONITOR_DATA_VAL bitfield
478 * @ref_rate: DFLL reference clock rate
479 *
480 * Convert @monitor_data from DFLL_MONITOR_DATA_VAL units into cycles
481 * per second. Returns the converted value.
482 */
483static u64 dfll_calc_monitored_rate(u32 monitor_data,
484 unsigned long ref_rate)
485{
486 return monitor_data * (ref_rate / REF_CLK_CYC_PER_DVCO_SAMPLE);
487}
488
489/**
490 * dfll_read_monitor_rate - return the DFLL's output rate from internal monitor
491 * @td: DFLL instance
492 *
493 * If the DFLL is enabled, return the last rate reported by the DFLL's
494 * internal monitoring hardware. This works in both open-loop and
495 * closed-loop mode, and takes the output scaler setting into account.
496 * Assumes that the monitor was programmed to monitor frequency before
497 * the sample period started. If the driver believes that the DFLL is
498 * currently uninitialized or disabled, it will return 0, since
499 * otherwise the DFLL monitor data register will return the last
500 * measured rate from when the DFLL was active.
501 */
502static u64 dfll_read_monitor_rate(struct tegra_dfll *td)
503{
504 u32 v, s;
505 u64 pre_scaler_rate, post_scaler_rate;
506
507 if (!dfll_is_running(td))
508 return 0;
509
510 v = dfll_readl(td, DFLL_MONITOR_DATA);
511 v = (v & DFLL_MONITOR_DATA_VAL_MASK) >> DFLL_MONITOR_DATA_VAL_SHIFT;
512 pre_scaler_rate = dfll_calc_monitored_rate(v, td->ref_rate);
513
514 s = dfll_readl(td, DFLL_FREQ_REQ);
515 s = (s & DFLL_FREQ_REQ_SCALE_MASK) >> DFLL_FREQ_REQ_SCALE_SHIFT;
516 post_scaler_rate = dfll_scale_dvco_rate(s, pre_scaler_rate);
517
518 return post_scaler_rate;
519}
520
521/*
522 * DFLL mode switching 472 * DFLL mode switching
523 */ 473 */
524 474
@@ -1096,6 +1046,55 @@ static void dfll_unregister_clk(struct tegra_dfll *td)
1096 */ 1046 */
1097 1047
1098#ifdef CONFIG_DEBUG_FS 1048#ifdef CONFIG_DEBUG_FS
1049/*
1050 * Monitor control
1051 */
1052
1053/**
1054 * dfll_calc_monitored_rate - convert DFLL_MONITOR_DATA_VAL rate into real freq
1055 * @monitor_data: value read from the DFLL_MONITOR_DATA_VAL bitfield
1056 * @ref_rate: DFLL reference clock rate
1057 *
1058 * Convert @monitor_data from DFLL_MONITOR_DATA_VAL units into cycles
1059 * per second. Returns the converted value.
1060 */
1061static u64 dfll_calc_monitored_rate(u32 monitor_data,
1062 unsigned long ref_rate)
1063{
1064 return monitor_data * (ref_rate / REF_CLK_CYC_PER_DVCO_SAMPLE);
1065}
1066
1067/**
1068 * dfll_read_monitor_rate - return the DFLL's output rate from internal monitor
1069 * @td: DFLL instance
1070 *
1071 * If the DFLL is enabled, return the last rate reported by the DFLL's
1072 * internal monitoring hardware. This works in both open-loop and
1073 * closed-loop mode, and takes the output scaler setting into account.
1074 * Assumes that the monitor was programmed to monitor frequency before
1075 * the sample period started. If the driver believes that the DFLL is
1076 * currently uninitialized or disabled, it will return 0, since
1077 * otherwise the DFLL monitor data register will return the last
1078 * measured rate from when the DFLL was active.
1079 */
1080static u64 dfll_read_monitor_rate(struct tegra_dfll *td)
1081{
1082 u32 v, s;
1083 u64 pre_scaler_rate, post_scaler_rate;
1084
1085 if (!dfll_is_running(td))
1086 return 0;
1087
1088 v = dfll_readl(td, DFLL_MONITOR_DATA);
1089 v = (v & DFLL_MONITOR_DATA_VAL_MASK) >> DFLL_MONITOR_DATA_VAL_SHIFT;
1090 pre_scaler_rate = dfll_calc_monitored_rate(v, td->ref_rate);
1091
1092 s = dfll_readl(td, DFLL_FREQ_REQ);
1093 s = (s & DFLL_FREQ_REQ_SCALE_MASK) >> DFLL_FREQ_REQ_SCALE_SHIFT;
1094 post_scaler_rate = dfll_scale_dvco_rate(s, pre_scaler_rate);
1095
1096 return post_scaler_rate;
1097}
1099 1098
1100static int attr_enable_get(void *data, u64 *val) 1099static int attr_enable_get(void *data, u64 *val)
1101{ 1100{