power: smb347-charger: Summit SMB358 charger IC
Subsystems (2)
PATCH 1/1 power: smb347-charger: Summit SMB358 charger IC
Summit microelectronics' SMB358 charger chip has
almost the same register map and functionality.
voltage and current table are only differed.
SMB345 charger IC tested in nexus7
---
v2:
* incorporated code review from Rob Herring
gpio line added for Enable charging control, documentation bindings (vendor prefixes and unit suffixes)
--- .../bindings/power/supply/smb347_charger.txt | 73 +++++ drivers/power/supply/smb347-charger.c | 334 +++++++++++++-------- include/linux/power/smb347-charger.h | 4 +- 3 files changed, 283 insertions(+), 128 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/smb347_charger.txt
Documentation/devicetree/bindings/power/supply/smb347_charger.txt new file +73 -0
@@ -0,0 +1,73 @@ +smb347_charger bindings +~~~~~~~~~~~~~~~~~~~~~~~~ + +[Required porperties] +- compatible : "summit,smb345" + "summit,smb347" +- reg : Slave address for i2c interface +# At least one of following should be set + - enable-usb-charging + - enable-otg-charging + - enable-mains-charging + +[Optional properties] +- interrupt-parent : The phandle for the interrupt controller +- interrupts : Interrupt line index for mapping +- en-gpio : Enable charging control + : If this is not specified it will use SW (i2c interface) + +# Charging constraints +- max-chg-curr : microamps for charging Maximum current +- max-chg-volt : microvolts for charging Maximum voltage +- pre-chg-curr : microamps for Pre-charging current +- term-curr : microamps for Charging cycle termination current +- fast-volt-thershold : microvolts for Voltage threshold to transit to fast charge mode +- mains-curr-limit : micromaps for Maximum input current from AC/DC input +- usb-curr-limit : microamps for Maximum input current from USB input + +# Related thermometer monitoring (Degrees Celsius) +- chip-temp-threshold : Chip temperature for thermal regulaton. <100, 130> +- soft-cold-temp-limit : Cold battery temperature for soft alarm. <0, 15>* +- soft-hot-temp-limit : Hot battery temperature for soft alarm. <40, 55> +- hard-cold-temp-limit : Cold battery temperature for hard alarm. <0, 15>* +- hard-hot-temp-limit : Hot battery temperature for hard alarm. <55, 65> +(* The written temperature has +5'C offset. 0'C -> -5'C, 15'C -> 10'C) +- soft-comp-method : Soft temperature limit compensation method + (Not defined) : Use default setting + <0> : Compensation none + <1> : Charge current compensation + <2> : Voltage compensation + +Example: + smb345@6a { + compatible = "summit,smb345"; + reg = <0x6a>; + status = "okay"; + interrupt-parent = <&tlmm_pinmux>; + interrupts = <23 IRQ_TYPE_EDGE_BOTH>; + + max-chg-curr = <1800000>; + usb-curr-limit = <450000>; + + chip-temp-thershold = <110>; /* celsius */ + + enable-usb-charging; + enable-otg-charging; + }; + + smb347@7f { + compatible = "summit,smb347"; + reg = <0x7f>; + status = "okay"; + + max-chg-curr = <1800000>; + mains-curr-limit = <2000000>; + usb-curr-limit = <450000>; + + chip-temp-thershold = <110>; /* celsius */ + + en-gpios = <&tlmm_pinmux 54 GPIO_ACTIVE_HIGH>; + + enable-usb-charging; + enable-mains-charging; + };
drivers/power/supply/smb347-charger.c +207 -127
589 lines not on this page · raw message
include/linux/power/smb347-charger.h +3 -1
@@ -47,7 +47,7 @@ enum smb347_chg_enable {* @pre_charge_current: current (in uA) to use in pre-charging phase * @termination_current: current (in uA) used to determine when the * charging cycle terminates -* @pre_to_fast_voltage: voltage (in uV) treshold used for transitioning to +* @pre_to_fast_voltage: voltage (in uV) threshold used for transitioning to * pre-charge to fast charge mode * @mains_current_limit: maximum input current drawn from AC/DC input (in uA) * @usb_hc_current_limit: maximum input high current (in uA) drawn from USB
@@ -71,6 +71,7 @@ enum smb347_chg_enable {* @use_usb: USB input can be used * @use_usb_otg: USB OTG output can be used (not implemented yet) * @irq_gpio: GPIO number used for interrupts (%-1 if not used) +* @en_gpio: GPIO used for Enable input * @enable_control: how charging enable/disable is controlled * (driver/pin controls) *
@@ -111,6 +112,7 @@ struct smb347_charger_platform_data {bool use_usb;bool use_usb_otg;int irq_gpio; +struct gpio_desc *en_gpio;enum smb347_chg_enable enable_control; };
Signature · 6 lines
2.1.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Vinay-Simha-BN/power-smb347-charger-Summit-SMB358-charger-IC/20170802-054147 config: x86_64-randconfig-b0-08030519 (attached as .config) compiler: gcc-6…
Hi Vinay,
[auto build test ERROR on linus/master]
[also build test ERROR on v4.13-rc3 next-20170802]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Vinay-Simha-BN/power-smb347-charger-Summit-SMB358-charger-IC/20170802-054147
config: x86_64-randconfig-b0-08030519 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 All errors (new ones prefixed by >>):
drivers/power/supply/smb347-charger.c: In function 'smb347_probe':
>> drivers/power/supply/smb347-charger.c:1341:24: error: implicit declaration of function 'devm_gpiod_get' [-Werror=implicit-function-declaration]
smb->pdata->en_gpio = devm_gpiod_get(dev, "en", GPIOD_OUT_HIGH);
^~~~~~~~~~~~~~
>> drivers/power/supply/smb347-charger.c:1341:50: error: 'GPIOD_OUT_HIGH' undeclared (first use in this function)
smb->pdata->en_gpio = devm_gpiod_get(dev, "en", GPIOD_OUT_HIGH);
^~~~~~~~~~~~~~ drivers/power/supply/smb347-charger.c:1341:50: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors
vim +/devm_gpiod_get +1341 drivers/power/supply/smb347-charger.c
1273
1274 static int smb347_probe(struct i2c_client *client,
1275 const struct i2c_device_id *id)
1276 {
1277 struct power_supply_config mains_usb_cfg = {}, battery_cfg = {};
1278 struct device *dev = &client->dev;
1279 struct smb347_charger *smb;
1280 int ret;
1281
1282 smb = devm_kzalloc(dev, sizeof(*smb), GFP_KERNEL);
1283 if (!smb)
1284 return -ENOMEM;
1285
1286 smb->pdata = smb347_get_platdata(dev);
1287 if (IS_ERR_OR_NULL(smb->pdata))
1288 return -ENODEV;
1289
1290 if (!smb->pdata->use_mains && !smb->pdata->use_usb)
1291 return -EINVAL;
1292
1293 i2c_set_clientdata(client, smb);
1294
1295 mutex_init(&smb->lock);
1296 smb->id = id->driver_data;
1297 smb->dev = &client->dev;
1298
1299 smb->regmap = devm_regmap_init_i2c(client, &smb347_regmap);
1300 if (IS_ERR(smb->regmap))
1301 return PTR_ERR(smb->regmap);
1302
1303 ret = smb347_hw_init(smb);
1304 if (ret < 0)
1305 return ret;
1306
1307 mains_usb_cfg.supplied_to = battery;
1308 mains_usb_cfg.num_supplicants = ARRAY_SIZE(battery);
1309 mains_usb_cfg.drv_data = smb;
1310 if (smb->pdata->use_mains) {
1311 smb->mains = power_supply_register(dev, &smb347_mains_desc,
1312 &mains_usb_cfg);
1313 if (IS_ERR(smb->mains))
1314 return PTR_ERR(smb->mains);
1315 }
1316
1317 if (smb->pdata->use_usb) {
1318 smb->usb = power_supply_register(dev, &smb347_usb_desc,
1319 &mains_usb_cfg);
1320 if (IS_ERR(smb->usb)) {
1321 if (smb->pdata->use_mains)
1322 power_supply_unregister(smb->mains);
1323 return PTR_ERR(smb->usb);
1324 }
1325 }
1326
1327 battery_cfg.drv_data = smb;
1328 smb->battery = power_supply_register(dev, &smb347_battery_desc,
1329 &battery_cfg);
1330 if (IS_ERR(smb->battery)) {
1331 if (smb->pdata->use_usb)
1332 power_supply_unregister(smb->usb);
1333 if (smb->pdata->use_mains)
1334 power_supply_unregister(smb->mains);
1335 return PTR_ERR(smb->battery);
1336 }
1337
1338 /*
1339 * EN - enable input can be controlled by i2c or gpio.
1340 */
> 1341 smb->pdata->en_gpio = devm_gpiod_get(dev, "en", GPIOD_OUT_HIGH);
1342 if (IS_ERR(smb->pdata->en_gpio)) {
1343 ret = PTR_ERR(smb->pdata->en_gpio);
1344 dev_err(dev, "cannot get en-gpio %d\n", ret);
1345 dev_dbg(smb->dev, "charging enable/disable in SW enabled\n");
1346
1347 smb->pdata->enable_control = SMB347_CHG_ENABLE_SW;
1348 } else {
1349 smb->pdata->enable_control = SMB347_CHG_ENABLE_PIN_ACTIVE_HIGH;
1350 }
1351
1352 /*
1353 * Interrupt pin is optional. If it is connected, we setup the
1354 * interrupt support here.
1355 */
1356 if (smb->pdata->irq_gpio >= 0) {
1357 ret = smb347_irq_init(smb, client);
1358 if (ret < 0) {
1359 dev_warn(dev, "failed to initialize IRQ: %d\n", ret);
1360 dev_warn(dev, "disabling IRQ support\n");
1361 } else {
1362 smb347_irq_enable(smb);
1363 }
1364 }
1365
1366 return 0;
1367 }
1368
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
In the config attached. CONFIG_GPIOLIB is not set. please set and recompile
fyi,devm_gpiod_get() declared in drivers/gpio/devres.c -> CONFIG_GPIOLIB
Quoted 128 lines · kbuild test robot
Hi Vinay,
[auto build test ERROR on linus/master]
[also build test ERROR on v4.13-rc3 next-20170802]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://github.com/0day-ci/linux/commits/Vinay-Simha-BN/power-smb347-charger-Summit-SMB358-charger-IC/20170802-054147
config: x86_64-randconfig-b0-08030519 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:# save the attached .config to linux build tree make ARCH=x86_64All errors (new ones prefixed by >>):
drivers/power/supply/smb347-charger.c: In function 'smb347_probe':Quoted 1 line
Quoted 1 line
drivers/power/supply/smb347-charger.c:1341:24: error: implicit declaration of function 'devm_gpiod_get' [-Werror=implicit-function-declaration]smb->pdata->en_gpio = devm_gpiod_get(dev, "en", GPIOD_OUT_HIGH); ^~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
drivers/power/supply/smb347-charger.c:1341:50: error: 'GPIOD_OUT_HIGH' undeclared (first use in this function)smb->pdata->en_gpio = devm_gpiod_get(dev, "en", GPIOD_OUT_HIGH); ^~~~~~~~~~~~~~
drivers/power/supply/smb347-charger.c:1341:50: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errorsvim +/devm_gpiod_get +1341
drivers/power/supply/smb347-charger.c1273
1274 static int smb347_probe(structi2c_client*client,
1275 const structi2c_device_id*id)
1276 {1277 struct power_supply_config mains_usb_cfg = {}, battery_cfg = {}; 1278 struct device *dev = &client->dev; 1279 struct smb347_charger *smb; 1280 int ret; 1281 1282 smb = devm_kzalloc(dev, sizeof(*smb), GFP_KERNEL); 1283 if (!smb) 1284 return -ENOMEM; 1285 1286 smb->pdata = smb347_get_platdata(dev); 1287 if (IS_ERR_OR_NULL(smb->pdata)) 1288 return -ENODEV; 1289 1290 if (!smb->pdata->use_mains && !smb->pdata->use_usb) 1291 return -EINVAL; 1292 1293 i2c_set_clientdata(client, smb); 1294 1295 mutex_init(&smb->lock); 1296 smb->id = id->driver_data; 1297 smb->dev = &client->dev; 1298 1299 smb->regmap = devm_regmap_init_i2c(client, &smb347_regmap); 1300 if (IS_ERR(smb->regmap)) 1301 return PTR_ERR(smb->regmap); 1302 1303 ret = smb347_hw_init(smb); 1304 if (ret < 0) 1305 return ret; 1306 1307 mains_usb_cfg.supplied_to = battery; 1308 mains_usb_cfg.num_supplicants = ARRAY_SIZE(battery); 1309 mains_usb_cfg.drv_data = smb; 1310 if (smb->pdata->use_mains) {1311
smb->mains= power_supply_register(dev,&smb347_mains_desc,
1312&mains_usb_cfg);
1313 if (IS_ERR(smb->mains))
1314 returnPTR_ERR(smb->mains);
1315 }
1316
1317 if (smb->pdata->use_usb) {
1318smb->usb= power_supply_register(dev,&smb347_usb_desc,
1319&mains_usb_cfg);
1320 if (IS_ERR(smb->usb)) {
1321 if (smb->pdata->use_mains)
1322power_supply_unregister(smb->mains);
1323 returnPTR_ERR(smb->usb);
1324 }
1325 }
1326
1327 battery_cfg.drv_data = smb;
1328smb->battery= power_supply_register(dev,&smb347_battery_desc,
1329&battery_cfg);
1330 if (IS_ERR(smb->battery)) {
1331 if (smb->pdata->use_usb)
1332power_supply_unregister(smb->usb);
1333 if (smb->pdata->use_mains)
1334power_supply_unregister(smb->mains);
1335 returnPTR_ERR(smb->battery);
1336 }
1337
1338 /*
1339 * EN - enable input can be controlled by i2c or gpio.
1340 */Quoted 1 line
1341
smb->pdata->en_gpio=devm_gpiod_get(dev, "en", GPIOD_OUT_HIGH);1342 if (
IS_ERR(smb->pdata->en_gpio)) {1343 ret = PTR_ERR(smb->pdata->en_gpio); 1344 dev_err(dev, "cannot get en-gpio %d\n", ret); 1345 dev_dbg(smb->dev, "charging enable/disable in SW enabled\n"); 1346 1347 smb->pdata->enable_control = SMB347_CHG_ENABLE_SW; 1348 } else { 1349 smb->pdata->enable_control = SMB347_CHG_ENABLE_PIN_ACTIVE_HIGH; 1350 } 1351 1352 /* 1353 * Interrupt pin is optional. If it is connected, we setup the 1354 * interrupt support here. 1355 */1356 if (
smb->pdata->irq_gpio>= 0) {
1357 ret =smb347_irq_init(smb, client);
1358 if (ret < 0) {
1359dev_warn(dev, "failed to initialize IRQ: %d\n", ret);
1360dev_warn(dev, "disabling IRQ support\n");
1361 } else {
1362smb347_irq_enable(smb);
1363 }
1364 }
1365
1366 return 0;
1367 }
1368---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Signature · 2 lines
regards, vinaysimha
Rob Herring
maintainerQuoted 13 lines · Vinay Simha BN
Summit microelectronics' SMB358 charger chip has
almost the same register map and functionality.
voltage and current table are only differed.SMB345 charger IC tested in nexus7
Cc John Stultz <[email protected]>Cc Sumit Semwal <[email protected]>Cc Jonghwa Lee <[email protected]>Cc Chanwoo Choi <[email protected]>Cc Myungjoo Ham <[email protected]>Signed-off-by Vinay Simha BN <[email protected]>
Quoted 7 lines
---
v2:
* incorporated code review from Rob Herring
gpio line added for Enable charging control, documentation bindings (vendor prefixes and unit suffixes)--- .../bindings/power/supply/smb347_charger.txt | 73 +++++
Please split binding to a separate patch.
Quoted 12 lines
drivers/power/supply/smb347-charger.c | 334 +++++++++++++-------- include/linux/power/smb347-charger.h | 4 +- 3 files changed, 283 insertions(+), 128 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/smb347_charger.txtDocumentation/devicetree/bindings/power/supply/smb347_charger.txt new file +1
-0@@ -0,0 +1,73 @@ +smb347_charger bindings
Documentation/devicetree/bindings/power/supply/smb347_charger.txt line 11
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/smb347_charger.txt new file +10
-0+~~~~~~~~~~~~~~~~~~~~~~~~ + +[Required porperties] +- compatible : "summit,smb345" + "summit,smb347" +- reg : Slave address for i2c interface +# At least one of following should be set + - enable-usb-charging + - enable-otg-charging + - enable-mains-charging
As I wrote last time, I don't think these belong in DT.
Documentation/devicetree/bindings/power/supply/smb347_charger.txt line 16
Quoted 5 lines
Documentation/devicetree/bindings/power/supply/smb347_charger.txt new file +5
-0+ +[Optional properties] +- interrupt-parent : The phandle for the interrupt controller +- interrupts : Interrupt line index for mapping +- en-gpio : Enable charging control
enable-gpios
Documentation/devicetree/bindings/power/supply/smb347_charger.txt line 26
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/smb347_charger.txt new file +10
-0+ : If this is not specified it will use SW (i2c interface) + +# Charging constraints +- max-chg-curr : microamps for charging Maximum current +- max-chg-volt : microvolts for charging Maximum voltage +- pre-chg-curr : microamps for Pre-charging current +- term-curr : microamps for Charging cycle termination current +- fast-volt-thershold : microvolts for Voltage threshold to transit to fast charge mode +- mains-curr-limit : micromaps for Maximum input current from AC/DC input +- usb-curr-limit : microamps for Maximum input current from USB input
These are all properties of the battery, not the charger. See .../power/supply/battery.txt.
Documentation/devicetree/bindings/power/supply/smb347_charger.txt line 34
Quoted 8 lines
Documentation/devicetree/bindings/power/supply/smb347_charger.txt new file +8
-0+ +# Related thermometer monitoring (Degrees Celsius) +- chip-temp-threshold : Chip temperature for thermal regulaton. <100, 130> +- soft-cold-temp-limit : Cold battery temperature for soft alarm. <0, 15>* +- soft-hot-temp-limit : Hot battery temperature for soft alarm. <40, 55> +- hard-cold-temp-limit : Cold battery temperature for hard alarm. <0, 15>* +- hard-hot-temp-limit : Hot battery temperature for hard alarm. <55, 65> +(* The written temperature has +5'C offset. 0'C -> -5'C, 15'C -> 10'C)
These too should probably be common. If not they need vendor prefix and unit suffix. See property-units.txt.
Quoted 14 lines
Documentation/devicetree/bindings/power/supply/smb347_charger.txt new file +14
-0+- soft-comp-method : Soft temperature limit compensation method + (Not defined) : Use default setting + <0> : Compensation none + <1> : Charge current compensation + <2> : Voltage compensation + +Example: + smb345@6a { + compatible = "summit,smb345"; + reg = <0x6a>; + status = "okay"; + interrupt-parent = <&tlmm_pinmux>; + interrupts = <23 IRQ_TYPE_EDGE_BOTH>; +
Documentation/devicetree/bindings/power/supply/smb347_charger.txt line 58
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/smb347_charger.txt new file +10
-0+ max-chg-curr = <1800000>; + usb-curr-limit = <450000>; + + chip-temp-thershold = <110>; /* celsius */ + + enable-usb-charging; + enable-otg-charging; + }; + + smb347@7f {
Isn't one example sufficient?
Quoted 15 lines
Documentation/devicetree/bindings/power/supply/smb347_charger.txt new file +15
-0+ compatible = "summit,smb347"; + reg = <0x7f>; + status = "okay"; + + max-chg-curr = <1800000>; + mains-curr-limit = <2000000>; + usb-curr-limit = <450000>; + + chip-temp-thershold = <110>; /* celsius */ + + en-gpios = <&tlmm_pinmux 54 GPIO_ACTIVE_HIGH>; + + enable-usb-charging; + enable-mains-charging; + };