]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/power/ab8500_btemp.c
drivers/rtc: dump small buffers via %*ph
[karo-tx-linux.git] / drivers / power / ab8500_btemp.c
index adebf6c6d1466a8a95b1c5824d89ad232e4453aa..07689064996ecccba2cfe5196b6826c364c2a687 100644 (file)
@@ -39,6 +39,9 @@
 #define BTEMP_BATCTRL_CURR_SRC_7UA     7
 #define BTEMP_BATCTRL_CURR_SRC_20UA    20
 
+#define BTEMP_BATCTRL_CURR_SRC_16UA    16
+#define BTEMP_BATCTRL_CURR_SRC_18UA    18
+
 #define to_ab8500_btemp_device_info(x) container_of((x), \
        struct ab8500_btemp, btemp_psy);
 
@@ -212,10 +215,18 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di,
 
        /* Only do this for batteries with internal NTC */
        if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) {
-               if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA)
-                       curr = BAT_CTRL_7U_ENA;
-               else
-                       curr = BAT_CTRL_20U_ENA;
+
+               if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
+                       if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_16UA)
+                               curr = BAT_CTRL_16U_ENA;
+                       else
+                               curr = BAT_CTRL_18U_ENA;
+               } else {
+                       if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA)
+                               curr = BAT_CTRL_7U_ENA;
+                       else
+                               curr = BAT_CTRL_20U_ENA;
+               }
 
                dev_dbg(di->dev, "Set BATCTRL %duA\n", di->curr_source);
 
@@ -246,11 +257,22 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di,
        } else if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) {
                dev_dbg(di->dev, "Disable BATCTRL curr source\n");
 
-               /* Write 0 to the curr bits */
-               ret = abx500_mask_and_set_register_interruptible(di->dev,
-                       AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
-                       BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA,
-                       ~(BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA));
+               if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
+                       /* Write 0 to the curr bits */
+                       ret = abx500_mask_and_set_register_interruptible(
+                               di->dev,
+                               AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
+                               BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA,
+                               ~(BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA));
+               } else {
+                       /* Write 0 to the curr bits */
+                       ret = abx500_mask_and_set_register_interruptible(
+                               di->dev,
+                               AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
+                               BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA,
+                               ~(BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA));
+               }
+
                if (ret) {
                        dev_err(di->dev, "%s failed disabling current source\n",
                                __func__);
@@ -292,11 +314,20 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di,
         * if we got an error above
         */
 disable_curr_source:
-       /* Write 0 to the curr bits */
-       ret = abx500_mask_and_set_register_interruptible(di->dev,
+       if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
+               /* Write 0 to the curr bits */
+               ret = abx500_mask_and_set_register_interruptible(di->dev,
+                       AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
+                       BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA,
+                       ~(BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA));
+       } else {
+               /* Write 0 to the curr bits */
+               ret = abx500_mask_and_set_register_interruptible(di->dev,
                        AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
                        BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA,
                        ~(BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA));
+       }
+
        if (ret) {
                dev_err(di->dev, "%s failed disabling current source\n",
                        __func__);
@@ -510,8 +541,11 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
 {
        int res;
        u8 i;
+       if (is_ab9540(di->parent) || is_ab8505(di->parent))
+               di->curr_source = BTEMP_BATCTRL_CURR_SRC_16UA;
+       else
+               di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA;
 
-       di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA;
        di->bm->batt_id = BATTERY_UNKNOWN;
 
        res =  ab8500_btemp_get_batctrl_res(di);
@@ -549,8 +583,13 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
         */
        if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL &&
                        di->bm->batt_id == 1) {
-               dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n");
-               di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA;
+               if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
+                       dev_dbg(di->dev, "Set BATCTRL current source to 16uA\n");
+                       di->curr_source = BTEMP_BATCTRL_CURR_SRC_16UA;
+               } else {
+                       dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n");
+                       di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA;
+               }
        }
 
        return di->bm->batt_id;
@@ -622,9 +661,9 @@ static irqreturn_t ab8500_btemp_templow_handler(int irq, void *_di)
 {
        struct ab8500_btemp *di = _di;
 
-       if (is_ab8500_2p0_or_earlier(di->parent)) {
+       if (is_ab8500_3p3_or_earlier(di->parent)) {
                dev_dbg(di->dev, "Ignore false btemp low irq"
-                       " for ABB cut 1.0, 1.1 and 2.0\n");
+                       " for ABB cut 1.0, 1.1, 2.0 and 3.3\n");
        } else {
                dev_crit(di->dev, "Battery temperature lower than -10deg c\n");
 
@@ -738,10 +777,10 @@ static int ab8500_btemp_get_temp(struct ab8500_btemp *di)
        int temp = 0;
 
        /*
-        * The BTEMP events are not reliabe on AB8500 cut2.0
+        * The BTEMP events are not reliabe on AB8500 cut3.3
         * and prior versions
         */
-       if (is_ab8500_2p0_or_earlier(di->parent)) {
+       if (is_ab8500_3p3_or_earlier(di->parent)) {
                temp = di->bat_temp * 10;
        } else {
                if (di->events.btemp_low) {
@@ -1030,8 +1069,8 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
                ab8500_btemp_periodic_work);
 
        /* Set BTEMP thermal limits. Low and Med are fixed */
-       di->btemp_ranges.btemp_low_limit = BTEMP_THERMAL_LOW_LIMIT * 10;
-       di->btemp_ranges.btemp_med_limit = BTEMP_THERMAL_MED_LIMIT * 10;
+       di->btemp_ranges.btemp_low_limit = BTEMP_THERMAL_LOW_LIMIT;
+       di->btemp_ranges.btemp_med_limit = BTEMP_THERMAL_MED_LIMIT;
 
        ret = abx500_get_register_interruptible(di->dev, AB8500_CHARGER,
                AB8500_BTEMP_HIGH_TH, &val);
@@ -1126,7 +1165,7 @@ static void __exit ab8500_btemp_exit(void)
        platform_driver_unregister(&ab8500_btemp_driver);
 }
 
-subsys_initcall_sync(ab8500_btemp_init);
+device_initcall(ab8500_btemp_init);
 module_exit(ab8500_btemp_exit);
 
 MODULE_LICENSE("GPL v2");