|
43 | 43 | REG_DESIGN_CAPACITY_CHARGE,
|
44 | 44 | REG_DESIGN_VOLTAGE_MIN,
|
45 | 45 | REG_DESIGN_VOLTAGE_MAX,
|
| 46 | + REG_CHEMISTRY, |
46 | 47 | REG_MANUFACTURER,
|
47 | 48 | REG_MODEL_NAME,
|
48 | 49 | };
|
@@ -133,7 +134,9 @@ static const struct chip_data {
|
133 | 134 | [REG_MANUFACTURER] =
|
134 | 135 | SBS_DATA(POWER_SUPPLY_PROP_MANUFACTURER, 0x20, 0, 65535),
|
135 | 136 | [REG_MODEL_NAME] =
|
136 |
| - SBS_DATA(POWER_SUPPLY_PROP_MODEL_NAME, 0x21, 0, 65535) |
| 137 | + SBS_DATA(POWER_SUPPLY_PROP_MODEL_NAME, 0x21, 0, 65535), |
| 138 | + [REG_CHEMISTRY] = |
| 139 | + SBS_DATA(POWER_SUPPLY_PROP_TECHNOLOGY, 0x22, 0, 65535) |
137 | 140 | };
|
138 | 141 |
|
139 | 142 | static enum power_supply_property sbs_properties[] = {
|
@@ -185,6 +188,7 @@ struct sbs_info {
|
185 | 188 |
|
186 | 189 | static char model_name[I2C_SMBUS_BLOCK_MAX + 1];
|
187 | 190 | static char manufacturer[I2C_SMBUS_BLOCK_MAX + 1];
|
| 191 | +static char chemistry[I2C_SMBUS_BLOCK_MAX + 1]; |
188 | 192 | static bool force_load;
|
189 | 193 |
|
190 | 194 | static int sbs_update_presence(struct sbs_info *chip, bool is_present)
|
@@ -636,6 +640,38 @@ static int sbs_get_property_index(struct i2c_client *client,
|
636 | 640 | return -EINVAL;
|
637 | 641 | }
|
638 | 642 |
|
| 643 | +static int sbs_get_chemistry(struct i2c_client *client, |
| 644 | + union power_supply_propval *val) |
| 645 | +{ |
| 646 | + enum power_supply_property psp = POWER_SUPPLY_PROP_TECHNOLOGY; |
| 647 | + int ret; |
| 648 | + |
| 649 | + ret = sbs_get_property_index(client, psp); |
| 650 | + if (ret < 0) |
| 651 | + return ret; |
| 652 | + |
| 653 | + ret = sbs_get_battery_string_property(client, ret, psp, |
| 654 | + chemistry); |
| 655 | + if (ret < 0) |
| 656 | + return ret; |
| 657 | + |
| 658 | + if (!strncasecmp(chemistry, "LION", 4)) |
| 659 | + val->intval = POWER_SUPPLY_TECHNOLOGY_LION; |
| 660 | + else if (!strncasecmp(chemistry, "LiP", 3)) |
| 661 | + val->intval = POWER_SUPPLY_TECHNOLOGY_LIPO; |
| 662 | + else if (!strncasecmp(chemistry, "NiCd", 4)) |
| 663 | + val->intval = POWER_SUPPLY_TECHNOLOGY_NiCd; |
| 664 | + else if (!strncasecmp(chemistry, "NiMH", 4)) |
| 665 | + val->intval = POWER_SUPPLY_TECHNOLOGY_NiMH; |
| 666 | + else |
| 667 | + val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; |
| 668 | + |
| 669 | + if (val->intval == POWER_SUPPLY_TECHNOLOGY_UNKNOWN) |
| 670 | + dev_warn(&client->dev, "Unknown chemistry: %s\n", chemistry); |
| 671 | + |
| 672 | + return 0; |
| 673 | +} |
| 674 | + |
639 | 675 | static int sbs_get_property(struct power_supply *psy,
|
640 | 676 | enum power_supply_property psp,
|
641 | 677 | union power_supply_propval *val)
|
@@ -673,7 +709,10 @@ static int sbs_get_property(struct power_supply *psy,
|
673 | 709 | break;
|
674 | 710 |
|
675 | 711 | case POWER_SUPPLY_PROP_TECHNOLOGY:
|
676 |
| - val->intval = POWER_SUPPLY_TECHNOLOGY_LION; |
| 712 | + ret = sbs_get_chemistry(client, val); |
| 713 | + if (ret < 0) |
| 714 | + break; |
| 715 | + |
677 | 716 | goto done; /* don't trigger power_supply_changed()! */
|
678 | 717 |
|
679 | 718 | case POWER_SUPPLY_PROP_ENERGY_NOW:
|
|
0 commit comments