mfd: pm8xxx-pwm: Add support for PM8038
Adapt the driver to take into consideration LPG
architecture of pmic 8038 and 8922. It does not
support 7-bit mode yet.
Change-Id: Ibfca90aae6fd9c90025af5364e1dcaf4a8bb3033
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
diff --git a/drivers/mfd/pm8xxx-pwm.c b/drivers/mfd/pm8xxx-pwm.c
index b5e2092..05f02c4 100644
--- a/drivers/mfd/pm8xxx-pwm.c
+++ b/drivers/mfd/pm8xxx-pwm.c
@@ -27,8 +27,14 @@
#define PM8XXX_PWM_CHANNELS 3
-#define PM8XXX_LPG_BANKS 8
-#define PM8XXX_LPG_PWM_CHANNELS PM8XXX_LPG_BANKS
+/*
+ * For the lack of better term to distinguish functional
+ * differences, hereby, LPG version 0 (V0, v0) denotes
+ * PM8058/8921, and version 1 (V1, v1) denotes
+ * PM8922/8038.
+ */
+#define PM8XXX_LPG_V0_PWM_CHANNELS 8
+#define PM8XXX_LPG_V1_PWM_CHANNELS 6
#define PM8XXX_LPG_CTL_REGS 7
/* PM8XXX PWM */
@@ -149,12 +155,10 @@
#define NSEC_32768HZ (NSEC_PER_SEC / 32768)
#define NSEC_19P2MHZ (NSEC_PER_SEC / 19200000)
-#define CLK_PERIOD_MIN NSEC_19P2MHZ
-#define CLK_PERIOD_MAX NSEC_1024HZ
-
#define NUM_LPG_PRE_DIVIDE 4
#define NUM_PWM_PRE_DIVIDE 2
+#define PRE_DIVIDE_1 1 /* v1 */
#define PRE_DIVIDE_2 2
#define PRE_DIVIDE_3 3
#define PRE_DIVIDE_5 5
@@ -1339,11 +1343,19 @@
if (version == PM8XXX_VERSION_8921 ||
version == PM8XXX_VERSION_8058 ||
- version == PM8XXX_VERSION_8922) {
+ version == PM8XXX_VERSION_8922 ||
+ version == PM8XXX_VERSION_8038) {
chip->is_lpg_supported = 1;
}
if (chip->is_lpg_supported) {
- chip->pwm_channels = PM8XXX_LPG_PWM_CHANNELS;
+ if (version == PM8XXX_VERSION_8922 ||
+ version == PM8XXX_VERSION_8038) {
+ for (i = 0; i < NUM_CLOCKS; i++)
+ pt_t[0][i] /= PRE_DIVIDE_2;
+ chip->pwm_channels = PM8XXX_LPG_V1_PWM_CHANNELS;
+ } else {
+ chip->pwm_channels = PM8XXX_LPG_V0_PWM_CHANNELS;
+ }
chip->pwm_total_pre_divs = NUM_LPG_PRE_DIVIDE;
} else {
chip->pwm_channels = PM8XXX_PWM_CHANNELS;