max1720x_battery: rename maxfg tags

GBMS_TAG_MXSN: separate from EEPROM GBMS_TAG_SNUM
GBMS_TAG_MXCN: separate from EEPROM GBMS_TAG_BCNT
Rename maxfg_sr to max1720x: prevent register fail
due to same compared words "maxfg"

Bug: 181624931
Signed-off-by: Jenny Ho <[email protected]>
Change-Id: I7589406c6e87a1bac03b695cb37f228f854ae82b
diff --git a/max1720x_battery.c b/max1720x_battery.c
index 13aaf6e..6dd29c3 100644
--- a/max1720x_battery.c
+++ b/max1720x_battery.c
@@ -4320,6 +4320,7 @@
 {
 	struct max1720x_chip *chip = (struct max1720x_chip *)ptr;
 	static gbms_tag_t keys[] = {GBMS_TAG_SNUM, GBMS_TAG_BCNT,
+				    GBMS_TAG_MXSN, GBMS_TAG_MXCN,
 				    GBMS_TAG_RAVG, GBMS_TAG_RFCN,
 				    GBMS_TAG_CMPC, GBMS_TAG_DXAC};
 	const int count = ARRAY_SIZE(keys);
@@ -4345,6 +4346,7 @@
 
 	switch (tag) {
 	case GBMS_TAG_SNUM:
+	case GBMS_TAG_MXSN:
 		reg = max17x0x_find_by_tag(&chip->regmap_nvram,
 					   MAX17X0X_TAG_SNUM);
 		if (reg && reg->size > size)
@@ -4362,6 +4364,7 @@
 		break;
 
 	case GBMS_TAG_BCNT:
+	case GBMS_TAG_MXCN:
 		reg = max17x0x_find_by_tag(&chip->regmap_nvram,
 					   MAX17X0X_TAG_BCNT);
 		if (reg && reg->size != size)
@@ -4420,7 +4423,7 @@
 	struct max1720x_chip *chip = (struct max1720x_chip *)ptr;
 
 	switch (tag) {
-	case GBMS_TAG_BCNT:
+	case GBMS_TAG_MXCN:
 		reg = max17x0x_find_by_tag(&chip->regmap_nvram,
 					   MAX17X0X_TAG_BCNT);
 		if (reg && reg->size != size)
@@ -4535,11 +4538,18 @@
 /* this must be not blocking */
 static void max17x0x_read_serial_number(struct max1720x_chip *chip)
 {
+	struct device_node *node = chip->dev->of_node;
 	char buff[32] = {0};
+	u32 sn_source = EEPROM_SN;
 	int ret;
 
-	if (chip->gauge_type == MAX_M5_GAUGE_TYPE)
+	ret = of_property_read_u32(node, "maxim,read-batt-sn", &sn_source);
+	dev_info(chip->dev, "batt-sn source: %d (%d)\n", sn_source, ret);
+
+	if (sn_source == EEPROM_SN)
 		ret = gbms_storage_read(GBMS_TAG_MINF, buff, GBMS_MINF_LEN);
+	else if (sn_source == MAX1720X_SN)
+		ret = gbms_storage_read(GBMS_TAG_MXSN, buff, sizeof(chip->serial_number));
 	else
 		ret = gbms_storage_read(GBMS_TAG_SNUM, buff, sizeof(chip->serial_number));
 
@@ -4560,7 +4570,7 @@
 		/* TODO: move to max1720x1 */
 		if (chip->regmap_nvram.regmap) {
 			ret = gbms_storage_register(&max17x0x_storage_dsc,
-						    "maxfg_sr", chip);
+						    "max1720x", chip);
 			if (ret == -EBUSY)
 				ret = 0;
 		}