bms: qpnp-bms: Add QRD 4.35v 2000mAh battery data

Add data for QRD 4.35V 2000mAh battery. In pmic8x26 V1.0, batt_id pin
is connect to ground, so can't identify the battery using ADC, add
a battery type for QRD.

Change-Id: Ib54873210b6dce476c93c8e48942921e305b5d82
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 321040e..e352e39 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -288,7 +288,7 @@
 obj-$(CONFIG_MACH_MSM8930_FLUID) += board-8930-all.o board-8930-regulator-pm8038.o board-8930-regulator-pm8917.o
 obj-$(CONFIG_PM8921_BMS) += bms-batterydata.o bms-batterydata-desay.o batterydata-lib.o
 obj-$(CONFIG_QPNP_BMS) += bms-batterydata.o bms-batterydata-desay.o batterydata-lib.o
-obj-$(CONFIG_QPNP_BMS) += bms-batterydata-oem.o
+obj-$(CONFIG_QPNP_BMS) += bms-batterydata-oem.o bms-batterydata-qrd-4v35-2000mah.o
 obj-$(CONFIG_MACH_APQ8064_CDP) += board-8064-all.o board-8064-regulator.o
 obj-$(CONFIG_MACH_APQ8064_MTP) += board-8064-all.o board-8064-regulator.o
 obj-$(CONFIG_MACH_APQ8064_LIQUID) += board-8064-all.o board-8064-regulator.o
diff --git a/arch/arm/mach-msm/bms-batterydata-qrd-4v35-2000mah.c b/arch/arm/mach-msm/bms-batterydata-qrd-4v35-2000mah.c
new file mode 100644
index 0000000..8adf8ca
--- /dev/null
+++ b/arch/arm/mach-msm/bms-batterydata-qrd-4v35-2000mah.c
@@ -0,0 +1,117 @@
+/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <linux/mfd/pm8xxx/batterydata-lib.h>
+
+static struct single_row_lut fcc_temp = {
+	.x		= {-20, 0, 25, 40, 60},
+	.y		= {2096, 2124, 2121, 2118, 2103},
+	.cols	= 5
+};
+
+static struct single_row_lut fcc_sf = {
+	.x		= {0},
+	.y		= {100},
+	.cols	= 1
+};
+
+static struct sf_lut rbatt_sf = {
+	.rows		= 30,
+	.cols		= 5,
+	.row_entries		= {-20, 0, 25, 40, 60},
+	.percent	= {100, 95, 90, 85, 80, 75, 70, 65, 60,
+		55, 50, 45, 40, 35, 30, 25, 20, 16, 13,
+		11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
+	.sf		= {
+				{2422, 324, 100, 79, 72},
+				{2417, 325, 100, 79, 71},
+				{2344, 327, 100, 80, 72},
+				{2416, 336, 102, 81, 73},
+				{2072, 354, 107, 82, 73},
+				{1961, 372, 113, 84, 75},
+				{1929, 341, 118, 87, 77},
+				{1929, 321, 130, 93, 80},
+				{2041, 306, 140, 104, 85},
+				{2202, 292, 119, 96, 83},
+				{2374, 290, 98, 80, 73},
+				{2550, 292, 98, 79, 72},
+				{2727, 294, 99, 81, 73},
+				{2904, 303, 100, 82, 75},
+				{3091, 323, 100, 81, 73},
+				{3278, 348, 100, 80, 73},
+				{3470, 376, 99, 79, 72},
+				{3627, 386, 100, 79, 72},
+				{3672, 398, 100, 80, 71},
+				{3812, 424, 100, 80, 73},
+				{3895, 443, 101, 80, 73},
+				{3985, 465, 102, 82, 75},
+				{4094, 497, 105, 83, 76},
+				{4211, 533, 109, 85, 79},
+				{4335, 579, 113, 87, 80},
+				{4505, 612, 113, 85, 76},
+				{4693, 643, 113, 86, 77},
+				{4930, 712, 120, 90, 81},
+				{5283, 835, 145, 111, 107},
+				{10293, 15765, 5566, 6904, 2547},
+	}
+};
+
+static struct pc_temp_ocv_lut pc_temp_ocv = {
+	.rows		= 31,
+	.cols		= 5,
+	.temp		= {-20, 0, 25, 40, 60},
+	.percent	= {100, 95, 90, 85, 80, 75, 70, 65, 60,
+		55, 50, 45, 40, 35, 30, 25, 20, 16, 13,
+		11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+	.ocv		= {
+				{4340, 4340, 4335, 4330, 4323},
+				{4217, 4260, 4265, 4263, 4258},
+				{4135, 4203, 4207, 4205, 4201},
+				{4084, 4150, 4152, 4150, 4146},
+				{3992, 4101, 4101, 4097, 4093},
+				{3934, 4049, 4051, 4046, 4044},
+				{3889, 3974, 3995, 3998, 3999},
+				{3852, 3926, 3958, 3961, 3959},
+				{3832, 3892, 3921, 3923, 3921},
+				{3819, 3859, 3874, 3877, 3877},
+				{3807, 3831, 3838, 3838, 3838},
+				{3796, 3809, 3815, 3815, 3814},
+				{3784, 3792, 3797, 3797, 3796},
+				{3770, 3780, 3783, 3782, 3781},
+				{3754, 3770, 3772, 3769, 3764},
+				{3737, 3758, 3763, 3754, 3742},
+				{3717, 3737, 3744, 3735, 3720},
+				{3700, 3713, 3718, 3710, 3696},
+				{3687, 3701, 3692, 3683, 3671},
+				{3674, 3695, 3689, 3681, 3669},
+				{3667, 3692, 3688, 3680, 3669},
+				{3659, 3690, 3687, 3680, 3668},
+				{3649, 3687, 3685, 3678, 3667},
+				{3636, 3683, 3683, 3676, 3664},
+				{3618, 3674, 3679, 3671, 3658},
+				{3596, 3652, 3663, 3652, 3632},
+				{3566, 3611, 3620, 3606, 3584},
+				{3522, 3547, 3555, 3540, 3517},
+				{3460, 3449, 3461, 3446, 3424},
+				{3356, 3282, 3312, 3299, 3273},
+				{3000, 3000, 3000, 3000, 3000}
+	}
+};
+
+
+struct bms_battery_data QRD_4v35_2000mAh_data = {
+	.fcc				= 2000,
+	.fcc_temp_lut			= &fcc_temp,
+	.fcc_sf_lut				= &fcc_sf,
+	.pc_temp_ocv_lut		= &pc_temp_ocv,
+	.rbatt_sf_lut			= &rbatt_sf,
+	.default_rbatt_mohm	= 172
+};
diff --git a/drivers/power/qpnp-bms.c b/drivers/power/qpnp-bms.c
index eac8953..9a642d6 100644
--- a/drivers/power/qpnp-bms.c
+++ b/drivers/power/qpnp-bms.c
@@ -2503,6 +2503,8 @@
 		batt_data = &palladium_1500_data;
 	} else if (chip->batt_type == BATT_OEM) {
 		batt_data = &oem_batt_data;
+	} else if (chip->batt_type == BATT_QRD_4V35_2000MAH) {
+		batt_data = &QRD_4v35_2000mAh_data;
 	} else {
 		battery_id = read_battery_id(chip);
 		if (battery_id < 0) {
diff --git a/include/linux/mfd/pm8xxx/batterydata-lib.h b/include/linux/mfd/pm8xxx/batterydata-lib.h
index df9569b..47a2b7b 100644
--- a/include/linux/mfd/pm8xxx/batterydata-lib.h
+++ b/include/linux/mfd/pm8xxx/batterydata-lib.h
@@ -18,10 +18,10 @@
 #define FCC_CC_COLS		5
 #define FCC_TEMP_COLS		8
 
-#define PC_CC_ROWS             29
+#define PC_CC_ROWS             31
 #define PC_CC_COLS             13
 
-#define PC_TEMP_ROWS		29
+#define PC_TEMP_ROWS		31
 #define PC_TEMP_COLS		8
 
 #define MAX_SINGLE_LUT_COLS	20
@@ -74,6 +74,7 @@
 	BATT_PALLADIUM,
 	BATT_DESAY,
 	BATT_OEM,
+	BATT_QRD_4V35_2000MAH,
 };
 
 /**
@@ -114,6 +115,7 @@
 extern struct bms_battery_data  palladium_1500_data;
 extern struct bms_battery_data  desay_5200_data;
 extern struct bms_battery_data  oem_batt_data;
+extern struct bms_battery_data QRD_4v35_2000mAh_data;
 
 int interpolate_fcc(struct single_row_lut *fcc_temp_lut, int batt_temp);
 int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc);