diff options
author | Lee Jones <lee.jones@linaro.org> | 2013-02-26 09:02:31 -0500 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2013-03-06 23:28:28 -0500 |
commit | bc6b4132bcae4b8e59766ba2dae8f377009b26d0 (patch) | |
tree | 16cd4e757c0a20fa6fb888a2b35b46e2a6084201 /drivers/mfd/ab8500-gpadc.c | |
parent | e4bffe8d8ad9856143b6e941a17870aee37413d7 (diff) |
mfd: ab8500-debug: Add support for the AB8540
Allow GPADC debug information to be shown when executing on an AB8540
based platform.
Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@stericsson.com>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
Reviewed-by: Philippe LANGLAIS <philippe.langlais@stericsson.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/ab8500-gpadc.c')
-rw-r--r-- | drivers/mfd/ab8500-gpadc.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c index c985b90577f6..e3535c74d5fe 100644 --- a/drivers/mfd/ab8500-gpadc.c +++ b/drivers/mfd/ab8500-gpadc.c | |||
@@ -135,6 +135,8 @@ enum cal_channels { | |||
135 | struct adc_cal_data { | 135 | struct adc_cal_data { |
136 | s64 gain; | 136 | s64 gain; |
137 | s64 offset; | 137 | s64 offset; |
138 | u16 otp_calib_hi; | ||
139 | u16 otp_calib_lo; | ||
138 | }; | 140 | }; |
139 | 141 | ||
140 | /** | 142 | /** |
@@ -829,6 +831,12 @@ static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc) | |||
829 | vmain_high = (((gpadc_cal[1] & 0xFF) << 2) | | 831 | vmain_high = (((gpadc_cal[1] & 0xFF) << 2) | |
830 | ((gpadc_cal[2] & 0xC0) >> 6)); | 832 | ((gpadc_cal[2] & 0xC0) >> 6)); |
831 | vmain_low = ((gpadc_cal[2] & 0x3E) >> 1); | 833 | vmain_low = ((gpadc_cal[2] & 0x3E) >> 1); |
834 | |||
835 | gpadc->cal_data[ADC_INPUT_VMAIN].otp_calib_hi = | ||
836 | (u16)vmain_high; | ||
837 | gpadc->cal_data[ADC_INPUT_VMAIN].otp_calib_lo = | ||
838 | (u16)vmain_low; | ||
839 | |||
832 | gpadc->cal_data[ADC_INPUT_VMAIN].gain = CALIB_SCALE * | 840 | gpadc->cal_data[ADC_INPUT_VMAIN].gain = CALIB_SCALE * |
833 | (19500 - 315) / (vmain_high - vmain_low); | 841 | (19500 - 315) / (vmain_high - vmain_low); |
834 | gpadc->cal_data[ADC_INPUT_VMAIN].offset = CALIB_SCALE * | 842 | gpadc->cal_data[ADC_INPUT_VMAIN].offset = CALIB_SCALE * |
@@ -856,6 +864,11 @@ static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc) | |||
856 | ibat_low = (((gpadc_otp4[1] & 0x01) << 5) | | 864 | ibat_low = (((gpadc_otp4[1] & 0x01) << 5) | |
857 | ((gpadc_otp4[2] & 0xF8) >> 3)); | 865 | ((gpadc_otp4[2] & 0xF8) >> 3)); |
858 | 866 | ||
867 | gpadc->cal_data[ADC_INPUT_IBAT].otp_calib_hi = | ||
868 | (u16)ibat_high; | ||
869 | gpadc->cal_data[ADC_INPUT_IBAT].otp_calib_lo = | ||
870 | (u16)ibat_low; | ||
871 | |||
859 | V_gain = ((IBAT_VDROP_H - IBAT_VDROP_L) | 872 | V_gain = ((IBAT_VDROP_H - IBAT_VDROP_L) |
860 | << CALIB_SHIFT_IBAT) / (ibat_high - ibat_low); | 873 | << CALIB_SHIFT_IBAT) / (ibat_high - ibat_low); |
861 | 874 | ||
@@ -892,6 +905,11 @@ static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc) | |||
892 | ((gpadc_cal[2] & 0xC0) >> 6)); | 905 | ((gpadc_cal[2] & 0xC0) >> 6)); |
893 | vmain_low = ((gpadc_cal[2] & 0x3E) >> 1); | 906 | vmain_low = ((gpadc_cal[2] & 0x3E) >> 1); |
894 | 907 | ||
908 | gpadc->cal_data[ADC_INPUT_VMAIN].otp_calib_hi = | ||
909 | (u16)vmain_high; | ||
910 | gpadc->cal_data[ADC_INPUT_VMAIN].otp_calib_lo = | ||
911 | (u16)vmain_low; | ||
912 | |||
895 | gpadc->cal_data[ADC_INPUT_VMAIN].gain = CALIB_SCALE * | 913 | gpadc->cal_data[ADC_INPUT_VMAIN].gain = CALIB_SCALE * |
896 | (19500 - 315) / (vmain_high - vmain_low); | 914 | (19500 - 315) / (vmain_high - vmain_low); |
897 | 915 | ||
@@ -902,12 +920,16 @@ static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc) | |||
902 | gpadc->cal_data[ADC_INPUT_VMAIN].gain = 0; | 920 | gpadc->cal_data[ADC_INPUT_VMAIN].gain = 0; |
903 | } | 921 | } |
904 | } | 922 | } |
923 | |||
905 | /* Calculate gain and offset for BTEMP if all reads succeeded */ | 924 | /* Calculate gain and offset for BTEMP if all reads succeeded */ |
906 | if (!(ret[2] < 0 || ret[3] < 0 || ret[4] < 0)) { | 925 | if (!(ret[2] < 0 || ret[3] < 0 || ret[4] < 0)) { |
907 | btemp_high = (((gpadc_cal[2] & 0x01) << 9) | | 926 | btemp_high = (((gpadc_cal[2] & 0x01) << 9) | |
908 | (gpadc_cal[3] << 1) | ((gpadc_cal[4] & 0x80) >> 7)); | 927 | (gpadc_cal[3] << 1) | ((gpadc_cal[4] & 0x80) >> 7)); |
909 | btemp_low = ((gpadc_cal[4] & 0x7C) >> 2); | 928 | btemp_low = ((gpadc_cal[4] & 0x7C) >> 2); |
910 | 929 | ||
930 | gpadc->cal_data[ADC_INPUT_BTEMP].otp_calib_hi = (u16)btemp_high; | ||
931 | gpadc->cal_data[ADC_INPUT_BTEMP].otp_calib_lo = (u16)btemp_low; | ||
932 | |||
911 | gpadc->cal_data[ADC_INPUT_BTEMP].gain = | 933 | gpadc->cal_data[ADC_INPUT_BTEMP].gain = |
912 | CALIB_SCALE * (1300 - 21) / (btemp_high - btemp_low); | 934 | CALIB_SCALE * (1300 - 21) / (btemp_high - btemp_low); |
913 | gpadc->cal_data[ADC_INPUT_BTEMP].offset = CALIB_SCALE * 1300 - | 935 | gpadc->cal_data[ADC_INPUT_BTEMP].offset = CALIB_SCALE * 1300 - |
@@ -922,6 +944,9 @@ static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc) | |||
922 | vbat_high = (((gpadc_cal[4] & 0x03) << 8) | gpadc_cal[5]); | 944 | vbat_high = (((gpadc_cal[4] & 0x03) << 8) | gpadc_cal[5]); |
923 | vbat_low = ((gpadc_cal[6] & 0xFC) >> 2); | 945 | vbat_low = ((gpadc_cal[6] & 0xFC) >> 2); |
924 | 946 | ||
947 | gpadc->cal_data[ADC_INPUT_VBAT].otp_calib_hi = (u16)vbat_high; | ||
948 | gpadc->cal_data[ADC_INPUT_VBAT].otp_calib_lo = (u16)vbat_low; | ||
949 | |||
925 | gpadc->cal_data[ADC_INPUT_VBAT].gain = CALIB_SCALE * | 950 | gpadc->cal_data[ADC_INPUT_VBAT].gain = CALIB_SCALE * |
926 | (4700 - 2380) / (vbat_high - vbat_low); | 951 | (4700 - 2380) / (vbat_high - vbat_low); |
927 | gpadc->cal_data[ADC_INPUT_VBAT].offset = CALIB_SCALE * 4700 - | 952 | gpadc->cal_data[ADC_INPUT_VBAT].offset = CALIB_SCALE * 4700 - |
@@ -1131,6 +1156,25 @@ static void __exit ab8500_gpadc_exit(void) | |||
1131 | platform_driver_unregister(&ab8500_gpadc_driver); | 1156 | platform_driver_unregister(&ab8500_gpadc_driver); |
1132 | } | 1157 | } |
1133 | 1158 | ||
1159 | /** | ||
1160 | * ab8540_gpadc_get_otp() - returns OTP values | ||
1161 | * | ||
1162 | */ | ||
1163 | void ab8540_gpadc_get_otp(struct ab8500_gpadc *gpadc, | ||
1164 | u16 *vmain_l, u16 *vmain_h, u16 *btemp_l, u16 *btemp_h, | ||
1165 | u16 *vbat_l, u16 *vbat_h, u16 *ibat_l, u16 *ibat_h) | ||
1166 | { | ||
1167 | *vmain_l = gpadc->cal_data[ADC_INPUT_VMAIN].otp_calib_lo; | ||
1168 | *vmain_h = gpadc->cal_data[ADC_INPUT_VMAIN].otp_calib_hi; | ||
1169 | *btemp_l = gpadc->cal_data[ADC_INPUT_BTEMP].otp_calib_lo; | ||
1170 | *btemp_h = gpadc->cal_data[ADC_INPUT_BTEMP].otp_calib_hi; | ||
1171 | *vbat_l = gpadc->cal_data[ADC_INPUT_VBAT].otp_calib_lo; | ||
1172 | *vbat_h = gpadc->cal_data[ADC_INPUT_VBAT].otp_calib_hi; | ||
1173 | *ibat_l = gpadc->cal_data[ADC_INPUT_IBAT].otp_calib_lo; | ||
1174 | *ibat_h = gpadc->cal_data[ADC_INPUT_IBAT].otp_calib_hi; | ||
1175 | return ; | ||
1176 | } | ||
1177 | |||
1134 | subsys_initcall_sync(ab8500_gpadc_init); | 1178 | subsys_initcall_sync(ab8500_gpadc_init); |
1135 | module_exit(ab8500_gpadc_exit); | 1179 | module_exit(ab8500_gpadc_exit); |
1136 | 1180 | ||