[COMMON] soc: samsung: Supplement DM sysfs info
authorHyeonseong Gil <hs.gil@samsung.com>
Mon, 18 Dec 2017 04:58:04 +0000 (13:58 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:26:09 +0000 (17:26 +0900)
Change-Id: Ide37abfbb8d3f3a328e595314e9fd63385b8d86c
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/soc/samsung/exynos-dm.c
include/soc/samsung/exynos-dm.h

index e7e2e57861a4375fc6009f3fa1c6badf62f2e466..aae995e9b2e445d42c0cde5d2984a570fe9cbb70 100644 (file)
@@ -150,9 +150,13 @@ static ssize_t show_dm_policy_##type_name                                          \
 {                                                                                      \
        struct platform_device *pdev = container_of(dev, struct platform_device, dev);  \
        struct exynos_dm_device *dm = platform_get_drvdata(pdev);                       \
+       struct list_head *constraint_list;                                              \
+       struct exynos_dm_constraint *constraint;                                        \
        ssize_t count = 0;                                                              \
        u32 gov_min_freq, min_freq, max_freq;                                           \
        u32 policy_min_freq, policy_max_freq, cur_freq, target_freq;                    \
+       u32 find;                                                                       \
+       int i;                                                                          \
                                                                                        \
        if (!dm->dm_data[dm_type].available) {                                          \
                count += snprintf(buf + count, PAGE_SIZE,                               \
@@ -179,7 +183,78 @@ static ssize_t show_dm_policy_##type_name                                          \
                        "min_freq = %u, max_freq = %u\n", min_freq, max_freq);          \
        count += snprintf(buf + count, PAGE_SIZE, "current_freq = %u\n", cur_freq);     \
        count += snprintf(buf + count, PAGE_SIZE, "target_freq = %u\n", target_freq);   \
+       count += snprintf(buf + count, PAGE_SIZE,                                       \
+                       "-------------------------------------------------\n");         \
+       count += snprintf(buf + count, PAGE_SIZE, "min constraint by\n");               \
+       find = 0;                                                                       \
                                                                                        \
+       for (i = 0; i < DM_TYPE_END; i++) {                                             \
+               if (!exynos_dm->dm_data[i].available)                                   \
+                       continue;                                                       \
+                                                                                       \
+               constraint_list = get_min_constraint_list(&exynos_dm->dm_data[i]);      \
+               if (list_empty(constraint_list))                                        \
+                       continue;                                                       \
+               list_for_each_entry(constraint, constraint_list, node) {                \
+                       if (constraint->constraint_dm_type == dm_type) {                \
+                               count += snprintf(buf + count, PAGE_SIZE,               \
+                                       "%s : %u ---> %s : %u",                         \
+                                       exynos_dm->dm_data[i].dm_type_name,             \
+                                       constraint->master_freq,                        \
+                                       constraint->dm_type_name,                       \
+                                       constraint->min_freq);                          \
+                               if (constraint->guidance)                               \
+                                       count += snprintf(buf+count, PAGE_SIZE,         \
+                                               " [guidance]\n");                       \
+                               else                                                    \
+                                       count += snprintf(buf+count, PAGE_SIZE, "\n");  \
+                               find = max(find, constraint->min_freq);                 \
+                       }                                                               \
+               }                                                                       \
+       }                                                                               \
+       if (find == 0)                                                                  \
+               count += snprintf(buf + count, PAGE_SIZE,                               \
+                               "There is no min constraint\n\n");                      \
+       else                                                                            \
+               count += snprintf(buf + count, PAGE_SIZE,                               \
+                               "min constraint freq = %u\n", find);                    \
+       count += snprintf(buf + count, PAGE_SIZE,                                       \
+                       "-------------------------------------------------\n");         \
+       count += snprintf(buf + count, PAGE_SIZE, "max constraint by\n");               \
+       find = INT_MAX;                                                                 \
+                                                                                       \
+       for (i = 0; i < DM_TYPE_END; i++) {                                             \
+               if (!exynos_dm->dm_data[i].available)                                   \
+                       continue;                                                       \
+                                                                                       \
+               constraint_list = get_max_constraint_list(&exynos_dm->dm_data[i]);      \
+               if (list_empty(constraint_list))                                        \
+                       continue;                                                       \
+               list_for_each_entry(constraint, constraint_list, node) {                \
+                       if (constraint->constraint_dm_type == dm_type) {                \
+                               count += snprintf(buf + count, PAGE_SIZE,               \
+                                       "%s : %u ---> %s : %u",                         \
+                                       exynos_dm->dm_data[i].dm_type_name,             \
+                                       constraint->master_freq,                        \
+                                       constraint->dm_type_name,                       \
+                                       constraint->max_freq);                          \
+                               if (constraint->guidance)                               \
+                                       count += snprintf(buf+count, PAGE_SIZE,         \
+                                               " [guidance]\n");                       \
+                               else                                                    \
+                                       count += snprintf(buf+count, PAGE_SIZE, "\n");  \
+                               find = min(find, constraint->max_freq);                 \
+                       }                                                               \
+               }                                                                       \
+       }                                                                               \
+       if (find == INT_MAX)                                                            \
+               count += snprintf(buf + count, PAGE_SIZE,                               \
+                               "There is no max constraint\n\n");                      \
+       else                                                                            \
+               count += snprintf(buf + count, PAGE_SIZE,                               \
+                               "max constraint freq = %u\n", find);                    \
+       count += snprintf(buf + count, PAGE_SIZE,                                       \
+                       "-------------------------------------------------\n");         \
        return count;                                                                   \
 }
 
@@ -723,6 +798,7 @@ static int constraint_checker_min(struct list_head *head, u32 freq)
                        for (i = constraint->table_length - 1; i >= 0; i--) {
                                if (freq <= constraint->freq_table[i].master_freq) {
                                        constraint->min_freq = constraint->freq_table[i].constraint_freq;
+                                       constraint->master_freq = freq;
                                        break;
                                }
                        }
index 287122c6570999cff31be7e2b4b1373f4a39662a..f4048c6595208f5421159deb42091ba64bf9eb64 100644 (file)
@@ -86,6 +86,7 @@ struct exynos_dm_constraint {
        struct exynos_dm_freq           *freq_table;
        u32                             min_freq;
        u32                             max_freq;
+       u32                             master_freq;
 
        struct exynos_dm_constraint     *sub_constraint;
 };