Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69fcbe56 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb135x-charger: Request HVDCP adapter to switch to 5V at shutdown"

parents dcabac7f 99618c07
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@
#define CFG_E_REG			0x0E
#define POLARITY_100_500_BIT		BIT(2)
#define USB_CTRL_BY_PIN_BIT		BIT(1)
#define HVDCP_5_9_BIT			BIT(4)

#define CFG_11_REG			0x11
#define PRIORITY_BIT			BIT(7)
@@ -3490,6 +3491,17 @@ static int smb135x_hw_init(struct smb135x_chg *chip)
		}
	}

	if (chip->usb_pullup_vreg) {
		/* enable 9V HVDCP adapter support */
		rc = smb135x_masked_write(chip, CFG_E_REG, HVDCP_5_9_BIT,
					HVDCP_5_9_BIT);
		if (rc < 0) {
			dev_err(chip->dev,
				"Couldn't request for 5 or 9V rc=%d\n", rc);
			goto free_regulator;
		}
	}

	__smb135x_charging(chip, chip->chg_enabled);

	/* interrupt enabling - active low */
@@ -4214,6 +4226,23 @@ static const struct i2c_device_id smb135x_charger_id[] = {
};
MODULE_DEVICE_TABLE(i2c, smb135x_charger_id);

static void smb135x_shutdown(struct i2c_client *client)
{
	int rc;
	struct smb135x_chg *chip = i2c_get_clientdata(client);

	if (chip->usb_pullup_vreg) {
		/*
		 * switch to 5V adapter to prevent any errorneous request of 12V
		 * when USB D+ line pull-up regulator turns off.
		 */
		rc = smb135x_masked_write(chip, CFG_E_REG, HVDCP_5_9_BIT, 0);
		if (rc < 0)
			dev_err(chip->dev,
				"Couldn't request for 5V rc=%d\n", rc);
	}
}

static struct i2c_driver smb135x_charger_driver = {
	.driver		= {
		.name		= "smb135x-charger",
@@ -4224,6 +4253,7 @@ static struct i2c_driver smb135x_charger_driver = {
	.probe		= smb135x_charger_probe,
	.remove		= smb135x_charger_remove,
	.id_table	= smb135x_charger_id,
	.shutdown	= smb135x_shutdown,
};

module_i2c_driver(smb135x_charger_driver);