summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorAnshul Jain <anshulj@nvidia.com>2013-03-26 20:55:10 -0700
committerSimone Willett <swillett@nvidia.com>2013-03-28 10:31:17 -0700
commit56298c4209906803d0d80ba987491ee183678074 (patch)
tree58c83900f244674922d26eff16548ab625a25e9c /drivers/thermal
parentc40024936ef8c85da1ae75bf5b0e53ac631cdfce (diff)
thermal: pwm_fan: Add support for look up table
This change adds a lookup table. This lookup table is used for looking up the pwm state cap based on the value echoed in state_cap sysfs node. Bug 1261177 Bug 1259488 Bug 1259204 Change-Id: Ie549d0a89e412655cd91d1f6321cd095af07071c Signed-off-by: Anshul Jain <anshulj@nvidia.com> Reviewed-on: http://git-master/r/213402 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Matt Wagner <mwagner@nvidia.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/pwm_fan.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/thermal/pwm_fan.c b/drivers/thermal/pwm_fan.c
index e2c11fb13be1..df736557b627 100644
--- a/drivers/thermal/pwm_fan.c
+++ b/drivers/thermal/pwm_fan.c
@@ -43,6 +43,7 @@ struct fan_dev_data {
int *fan_pwm;
int *fan_rru;
int *fan_rrd;
+ int *fan_state_cap_lookup;
struct workqueue_struct *workqueue;
int fan_temp_control_flag;
struct pwm_device *pwm_dev;
@@ -561,14 +562,18 @@ static ssize_t set_fan_state_cap_sysfs(struct device *dev,
if (val < 0)
val = 0;
- else if (val >= MAX_ACTIVE_STATES)
- val = MAX_ACTIVE_STATES - 1;
+ else if (val >= fan_data->active_steps)
+ val = fan_data->active_steps - 1;
mutex_lock(&fan_data->fan_state_lock);
fan_data->fan_state_cap = val;
- fan_data->fan_cap_pwm = fan_data->fan_pwm[val];
+ fan_data->fan_cap_pwm =
+ fan_data->fan_pwm[fan_data->fan_state_cap_lookup[val]];
fan_data->next_target_pwm = min(fan_data->fan_cap_pwm,
fan_data->next_target_pwm);
+ dev_info(dev, "pwm_cap=%d target_pwm=%d\n",
+ fan_data->fan_cap_pwm, fan_data->next_target_pwm);
+
mutex_unlock(&fan_data->fan_state_lock);
return count;
}
@@ -623,7 +628,7 @@ static int __devinit pwm_fan_probe(struct platform_device *pdev)
return -ENOMEM;
rpm_data = devm_kzalloc(&pdev->dev,
- 4 * sizeof(int) * data->active_steps, GFP_KERNEL);
+ 5 * sizeof(int) * data->active_steps, GFP_KERNEL);
if (!rpm_data)
return -ENOMEM;
@@ -631,6 +636,8 @@ static int __devinit pwm_fan_probe(struct platform_device *pdev)
fan_data->fan_pwm = rpm_data + data->active_steps;
fan_data->fan_rru = fan_data->fan_pwm + data->active_steps;
fan_data->fan_rrd = fan_data->fan_rru + data->active_steps;
+ fan_data->fan_state_cap_lookup = fan_data->fan_rrd + data->active_steps;
+
mutex_init(&fan_data->fan_state_lock);
fan_data->workqueue = alloc_workqueue(dev_name(&pdev->dev),
@@ -652,11 +659,14 @@ static int __devinit pwm_fan_probe(struct platform_device *pdev)
fan_data->fan_pwm[i] = data->active_pwm[i];
fan_data->fan_rru[i] = data->active_rru[i];
fan_data->fan_rrd[i] = data->active_rrd[i];
- dev_info(&pdev->dev, "rpm=%d, pwm=%d, rru=%d, rrd=%d\n",
- fan_data->fan_rpm[i],
- fan_data->fan_pwm[i],
- fan_data->fan_rru[i],
- fan_data->fan_rrd[i]);
+ fan_data->fan_state_cap_lookup[i] = data->state_cap_lookup[i];
+ dev_info(&pdev->dev,
+ "rpm=%d, pwm=%d, rru=%d, rrd=%d state:%d\n",
+ fan_data->fan_rpm[i],
+ fan_data->fan_pwm[i],
+ fan_data->fan_rru[i],
+ fan_data->fan_rrd[i],
+ fan_data->fan_state_cap_lookup[i]);
}
fan_data->fan_cap_pwm = data->active_pwm[data->state_cap];
dev_info(&pdev->dev, "cap state:%d, cap pwm:%d\n",