qpnp: pwm: Rectify the LPG lookup table indices
Due to LPG hardware bug the pwm driver correctly skips the
first two bytes in the Lookup Table (LUT) when it performs the
table write. However, there exists a bug where it doesn't update
the correct LUT low and high indices. Since it skips only one
entry both at low and high index, it is difficult to spot the bug by
any practical means (i.e. visually when using LED in PWM mode).
CRs-fixed: 474759
Change-Id: Id9a78223e9888081bfa4689073f2b3de96e7a309
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
diff --git a/drivers/platform/msm/qpnp-pwm.c b/drivers/platform/msm/qpnp-pwm.c
index 1729b49..2d58ef5 100644
--- a/drivers/platform/msm/qpnp-pwm.c
+++ b/drivers/platform/msm/qpnp-pwm.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -463,7 +463,7 @@
int i, pwm_size, rc = 0;
int burst_size = SPMI_MAX_BUF_LEN;
int list_len = lut->list_len << 1;
- int offset = lut->lo_index << 1;
+ int offset = (lut->lo_index << 1) - 2;
pwm_size = QPNP_GET_PWM_SIZE(
chip->qpnp_lpg_registers[QPNP_LPG_PWM_SIZE_CLK]) &
@@ -1024,8 +1024,8 @@
raw_lut = 1;
lut_config->list_len = len;
- lut_config->lo_index = start_idx;
- lut_config->hi_index = start_idx + len - 1;
+ lut_config->lo_index = start_idx + 1;
+ lut_config->hi_index = start_idx + len;
rc = qpnp_lpg_change_table(pwm, duty_pct, raw_lut);
if (rc) {