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

Commit 01f4b260 authored by Guru Das Srinagesh's avatar Guru Das Srinagesh Committed by Umang Agrawal
Browse files

power: smb1355: Detect SMB1354



Add support for detecting whether the chip is SMB1355 or SMB1354 (a
variant of SMB1355). This is accomplished by reading the contents of the
REVID_MFG_ID_SPARE_REG.

CRs-Fixed: 2170280
Change-Id: I7799bfbdbda44f250ebec266ecf5adc0035398bf
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
Signed-off-by: default avatarUmang Agrawal <uagrawal@codeaurora.org>
parent fe4fe7b9
Loading
Loading
Loading
Loading
+43 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@

/* SMB1355 registers, different than mentioned in smb-reg.h */

#define REVID_BASE	0x0100
#define I2C_SS_DIG_BASE 0x0E00
#define CHGR_BASE	0x1000
#define ANA2_BASE	0x1100
@@ -39,6 +40,8 @@
#define ANA1_BASE	0x1400
#define MISC_BASE	0x1600

#define REVID_MFG_ID_SPARE_REG                  (REVID_BASE + 0xFF)

#define I2C_SS_DIG_PMIC_SID_REG			(I2C_SS_DIG_BASE + 0x45)
#define PMIC_SID_MASK				GENMASK(3, 0)
#define PMIC_SID0_BIT				BIT(0)
@@ -223,6 +226,8 @@ struct smb1355 {
	char			*name;
	struct regmap		*regmap;

	int			max_fcc;

	struct smb_dt_props	dt;
	struct smb_params	param;

@@ -784,6 +789,38 @@ static int smb1355_init_parallel_psy(struct smb1355 *chip)
 * HARDWARE INITIALIZATION *
 ***************************/

#define MFG_ID_SMB1354			0x01
#define MFG_ID_SMB1355			0xFF
#define SMB1354_MAX_PARALLEL_FCC_UA	2500000
#define SMB1355_MAX_PARALLEL_FCC_UA	6000000
static int smb1355_detect_version(struct smb1355 *chip)
{
	int rc;
	u8 val;

	rc = smb1355_read(chip, REVID_MFG_ID_SPARE_REG, &val);
	if (rc < 0) {
		pr_err("Unable to read REVID rc=%d\n", rc);
		return rc;
	}

	switch (val) {
	case MFG_ID_SMB1354:
		chip->name = "smb1354";
		chip->max_fcc = SMB1354_MAX_PARALLEL_FCC_UA;
		break;
	case MFG_ID_SMB1355:
		chip->name = "smb1355";
		chip->max_fcc = SMB1355_MAX_PARALLEL_FCC_UA;
		break;
	default:
		pr_err("Invalid value of REVID val=%d", val);
		return -EINVAL;
	}

	return rc;
}

static int smb1355_tskin_sensor_config(struct smb1355 *chip)
{
	int rc;
@@ -1192,7 +1229,6 @@ static int smb1355_probe(struct platform_device *pdev)
	chip->param = v1_params;
	chip->c_health = -EINVAL;
	chip->c_charger_temp_max = -EINVAL;
	chip->name = "smb1355";
	mutex_init(&chip->write_lock);
	INIT_DELAYED_WORK(&chip->die_temp_work, die_temp_work);
	chip->disabled = true;
@@ -1210,6 +1246,12 @@ static int smb1355_probe(struct platform_device *pdev)
		return -ENODEV;
	}

	rc = smb1355_detect_version(chip);
	if (rc < 0) {
		pr_err("Couldn't detect SMB1355/1354 chip type rc=%d\n", rc);
		goto cleanup;
	}

	platform_set_drvdata(pdev, chip);

	rc = smb1355_parse_dt(chip);