Commit 58a1c154 authored by Anton Vorontsov's avatar Anton Vorontsov
Browse files
Pull a huge ab8500/pm2301 pile of changes from Lee Jones. Lee did an
awesome job cleaning this stuff up and thus brought ab8500 Stericsson's
development tree much closer to the mainline. Even more changes to come,
though.

Conflicts:
	drivers/power/Kconfig
parents eeb0751c 34c11a70
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -749,6 +749,12 @@ static struct resource ab8500_charger_resources[] = {
		.end = AB8500_INT_CH_WD_EXP,
		.flags = IORESOURCE_IRQ,
	},
	{
		.name = "VBUS_CH_DROP_END",
		.start = AB8500_INT_VBUS_CH_DROP_END,
		.end = AB8500_INT_VBUS_CH_DROP_END,
		.flags = IORESOURCE_IRQ,
	},
};

static struct resource ab8500_btemp_resources[] = {
+7 −0
Original line number Diff line number Diff line
@@ -352,6 +352,13 @@ config BATTERY_GOLDFISH
	  Say Y to enable support for the battery and AC power in the
	  Goldfish emulator.

config CHARGER_PM2301
	bool "PM2301 Battery Charger Driver"
	depends on AB8500_BM
	help
	  Say Y to include support for PM2301 charger driver.
	  Depends on AB8500 battery management core.

source "drivers/power/reset/Kconfig"

endif # POWER_SUPPLY
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ obj-$(CONFIG_CHARGER_LP8727) += lp8727_charger.o
obj-$(CONFIG_CHARGER_LP8788)	+= lp8788-charger.o
obj-$(CONFIG_CHARGER_GPIO)	+= gpio-charger.o
obj-$(CONFIG_CHARGER_MANAGER)	+= charger-manager.o
obj-$(CONFIG_CHARGER_PM2301)	+= pm2301_charger.o
obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
obj-$(CONFIG_CHARGER_BQ2415X)	+= bq2415x_charger.o
+53 −14
Original line number Diff line number Diff line
@@ -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 (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");

		if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
			/* Write 0 to the curr bits */
		ret = abx500_mask_and_set_register_interruptible(di->dev,
			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:
	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->bm->batt_id = BATTERY_UNKNOWN;

	res =  ab8500_btemp_get_batctrl_res(di);
@@ -549,9 +583,14 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
	 */
	if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL &&
			di->bm->batt_id == 1) {
		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;
}
+472 −145

File changed.

Preview size limit exceeded, changes collapsed.

Loading