#define DM_EMPTY 0xFF
static struct exynos_dm_device *exynos_dm;
-static enum exynos_dm_type min_order[DM_TYPE_END + 1] = {DM_EMPTY, };
-static enum exynos_dm_type max_order[DM_TYPE_END + 1] = {DM_EMPTY, };
+static int *min_order;
+static int *max_order;
/*
* SYSFS for Debugging
ssize_t count = 0;
int i;
- for (i = 0; i < DM_TYPE_END; i++) {
+ for (i = 0; i < dm->domain_count; i++) {
if (!dm->dm_data[i].available)
continue;
count += snprintf(buf + count, PAGE_SIZE, "min constraint by\n");
find = 0;
- for (i = 0; i < DM_TYPE_END; i++) {
+ for (i = 0; i < exynos_dm->domain_count; i++) {
if (!exynos_dm->dm_data[i].available)
continue;
count += snprintf(buf + count, PAGE_SIZE, "max constraint by\n");
find = INT_MAX;
- for (i = 0; i < DM_TYPE_END; i++) {
+ for (i = 0; i < exynos_dm->domain_count; i++) {
if (!exynos_dm->dm_data[i].available)
continue;
{
int i;
- for (i = 0; i < DM_TYPE_END; i++) {
+ for (i = 0; i < dm->domain_count; i++) {
if (!dm->dm_data[i].available)
continue;
}
}
-static int exynos_dm_index_validate(enum exynos_dm_type index)
+static int exynos_dm_index_validate(int index)
{
- if ((index < 0) || (index >= DM_TYPE_END)) {
+ if (index < 0) {
dev_err(exynos_dm->dev, "invalid dm_index (%d)\n", index);
return -EINVAL;
}
#ifdef CONFIG_OF
static int exynos_dm_parse_dt(struct device_node *np, struct exynos_dm_device *dm)
{
- struct device_node *child_np;
+ struct device_node *child_np, *domain_np = NULL;
const char *name;
int ret = 0;
+ int i = 0;
if (!np)
return -ENODEV;
- for_each_child_of_node(np, child_np) {
+ domain_np = of_get_child_by_name(np, "dm_domains");
+ if (!domain_np)
+ return -ENODEV;
+
+ dm->domain_count = of_get_child_count(domain_np);
+ if (!dm->domain_count)
+ return -ENODEV;
+
+ dm->dm_data = kzalloc(sizeof(struct exynos_dm_data) * dm->domain_count, GFP_KERNEL);
+ if (!dm->dm_data) {
+ dev_err(dm->dev, "failed to allocate dm_data\n");
+ return -ENOMEM;
+ }
+
+ min_order = kzalloc(sizeof(int) * (dm->domain_count + 1), GFP_KERNEL);
+ if (!min_order) {
+ dev_err(dm->dev, "failed to allocate min_order\n");
+ return -ENOMEM;
+ }
+
+ max_order = kzalloc(sizeof(int) * (dm->domain_count + 1), GFP_KERNEL);
+ if (!max_order) {
+ dev_err(dm->dev, "failed to allocate max_order\n");
+ return -ENOMEM;
+ }
+
+ /* min/max order clear */
+ for (i = 0; i <= dm->domain_count; i++) {
+ min_order[i] = DM_EMPTY;
+ max_order[i] = DM_EMPTY;
+ }
+
+ for_each_child_of_node(domain_np, child_np) {
int index;
const char *available;
#ifdef CONFIG_EXYNOS_ACPM
old_min_freq = dm->min_freq;
dm->gov_min_freq = (u32)(*target_freq);
- for (i = 0; i < DM_TYPE_END; i++)
+ for (i = 0; i < exynos_dm->domain_count; i++)
(&exynos_dm->dm_data[i])->constraint_checked = 0;
if (dm->policy_max_freq < dm->cur_freq)
scaling_callback(DOWN, relation);
/* min/max order clear */
- for (i = 0; i <= DM_TYPE_END; i++) {
+ for (i = 0; i <= exynos_dm->domain_count; i++) {
min_order[i] = DM_EMPTY;
max_order[i] = DM_EMPTY;
}
max_freq = dm->policy_max_freq;
/* Check min/max constraint conditions */
- for (i = 0; i < DM_TYPE_END; i++) {
+ for (i = 0; i < exynos_dm->domain_count; i++) {
if (!exynos_dm->dm_data[i].available)
continue;
min_freq = max(min_freq, constraint->min_freq);
}
}
- for (i = 0; i < DM_TYPE_END; i++) {
+ for (i = 0; i < exynos_dm->domain_count; i++) {
if (!exynos_dm->dm_data[i].available)
continue;
switch (dir) {
case DOWN:
if (min_order[0] == 0 && max_flag == false) {
- for (i = 1; i <= DM_TYPE_END; i++) {
+ for (i = 1; i <= exynos_dm->domain_count; i++) {
if (min_order[i] == DM_EMPTY)
continue;
}
}
} else if (max_order[0] == 0 && max_flag == true) {
- for (i = DM_TYPE_END; i > 0; i--) {
+ for (i = exynos_dm->domain_count; i > 0; i--) {
if (max_order[i] == DM_EMPTY)
continue;
break;
case UP:
if (min_order[0] == 0) {
- for (i = DM_TYPE_END; i > 0; i--) {
+ for (i = exynos_dm->domain_count; i > 0; i--) {
if (min_order[i] == DM_EMPTY)
continue;
}
}
} else if (max_order[0] == 0) {
- for (i = 1; i <= DM_TYPE_END; i++) {
+ for (i = 1; i <= exynos_dm->domain_count; i++) {
if (max_order[i] == DM_EMPTY)
continue;
break;
}
- for (i = 1; i <= DM_TYPE_END; i++) {
+ for (i = 1; i <= exynos_dm->domain_count; i++) {
if (min_order[i] == DM_EMPTY)
continue;
if (ret)
dev_warn(dm->dev, "failed create sysfs for DVFS Manager\n");
- for (i = 0; i < DM_TYPE_END; i++) {
+ for (i = 0; i < dm->domain_count; i++) {
if (!dm->dm_data[i].available)
continue;