Lines Matching +full:regulator +full:- +full:input +full:- +full:current +full:- +full:limit +full:- +full:microamp
1 // SPDX-License-Identifier: GPL-2.0-only
21 #include <linux/regulator/driver.h>
23 #include <dt-bindings/power/summit,smb347-charger.h>
26 #define SMB3XX_SOFT_TEMP_COMPENSATE_DEFAULT -1
28 /* Use default factory programmed value for hard/soft temperature limit */
29 #define SMB3XX_TEMP_USE_DEFAULT -273
34 * reloaded from non-volatile registers after POR.
136 * struct smb347_charger - smb347 charger instance
141 * @usb_rdev: USB VBUS regulator device
143 * @mains_online: is AC/DC input connected
144 * @usb_online: is USB input connected
147 * @max_charge_current: maximum current (in uA) the battery can be charged
149 * @pre_charge_current: current (in uA) to use in pre-charging phase
150 * @termination_current: current (in uA) used to determine when the
153 * pre-charge to fast charge mode
154 * @mains_current_limit: maximum input current drawn from AC/DC input (in uA)
155 * @usb_hc_current_limit: maximum input high current (in uA) drawn from USB
156 * input
158 * current [%100 - %130] (in degree C)
159 * @soft_cold_temp_limit: soft cold temperature limit [%0 - %15] (in degree C),
161 * @soft_hot_temp_limit: soft hot temperature limit [%40 - %55] (in degree C),
163 * @hard_cold_temp_limit: hard cold temperature limit [%-5 - %10] (in degree C),
165 * @hard_hot_temp_limit: hard hot temperature limit [%50 - %65] (in degree C),
167 * @suspend_on_hard_temp_limit: suspend charging when hard limit is hit
169 * limit is hit
170 * @charge_current_compensation: current (in uA) for charging compensation
171 * current when temperature hits soft limits
172 * @use_mains: AC/DC input can be used
173 * @use_usb: USB input can be used
185 * Hard and soft temperature limit values are given as described in the
190 * hot limit to be %53 deg C, @hard_hot_temp_limit should be set to %50.
192 * If zero value is given in any of the current and voltage values, the
237 /* Fast charge current in uA */
246 /* Pre-charge current in uA */
253 /* Termination current in uA */
263 /* Input current limit in uA */
273 /* Charge current compensation in uA */
280 /* Convert register value to current using lookup table */
284 return -EINVAL; in hw_to_current()
288 /* Convert current to register value using lookup table */
296 return i > 0 ? i - 1 : -EINVAL; in current_to_hw()
300 * smb347_update_ps_status - refreshes the power source status
314 ret = regmap_read(smb->regmap, IRQSTAT_E, &val); in smb347_update_ps_status()
322 if (smb->use_mains) in smb347_update_ps_status()
324 if (smb->use_usb) in smb347_update_ps_status()
327 ret = smb->mains_online != dc || smb->usb_online != usb; in smb347_update_ps_status()
328 smb->mains_online = dc; in smb347_update_ps_status()
329 smb->usb_online = usb; in smb347_update_ps_status()
335 * smb347_is_ps_online - returns whether input power source is connected
338 * Returns %true if input power source is connected. Note that this is
345 return smb->usb_online || smb->mains_online; in smb347_is_ps_online()
349 * smb347_charging_status - returns status of charging
353 * %1 means pre-charging, %2 fast-charging and %3 taper-charging.
363 ret = regmap_read(smb->regmap, STAT_C, &val); in smb347_charging_status()
372 if (smb->enable_control != SMB3XX_CHG_ENABLE_SW) { in smb347_charging_set()
373 dev_dbg(smb->dev, "charging enable/disable in SW disabled\n"); in smb347_charging_set()
377 if (enable && smb->usb_vbus_enabled) { in smb347_charging_set()
378 dev_dbg(smb->dev, "charging not enabled because USB is in host mode\n"); in smb347_charging_set()
382 return regmap_update_bits(smb->regmap, CMD_A, CMD_A_CHG_ENABLED, in smb347_charging_set()
408 dev_err(smb->dev, "failed to enable charging\n"); in smb347_start_stop_charging()
412 dev_err(smb->dev, "failed to disable charging\n"); in smb347_start_stop_charging()
420 unsigned int id = smb->id; in smb347_set_charge_current()
423 if (smb->max_charge_current) { in smb347_set_charge_current()
425 smb->max_charge_current); in smb347_set_charge_current()
429 ret = regmap_update_bits(smb->regmap, CFG_CHARGE_CURRENT, in smb347_set_charge_current()
436 if (smb->pre_charge_current) { in smb347_set_charge_current()
438 smb->pre_charge_current); in smb347_set_charge_current()
442 ret = regmap_update_bits(smb->regmap, CFG_CHARGE_CURRENT, in smb347_set_charge_current()
449 if (smb->termination_current) { in smb347_set_charge_current()
451 smb->termination_current); in smb347_set_charge_current()
455 ret = regmap_update_bits(smb->regmap, CFG_CHARGE_CURRENT, in smb347_set_charge_current()
466 unsigned int id = smb->id; in smb347_set_current_limits()
469 if (smb->mains_current_limit) { in smb347_set_current_limits()
471 smb->mains_current_limit); in smb347_set_current_limits()
475 ret = regmap_update_bits(smb->regmap, CFG_CURRENT_LIMIT, in smb347_set_current_limits()
482 if (smb->usb_hc_current_limit) { in smb347_set_current_limits()
484 smb->usb_hc_current_limit); in smb347_set_current_limits()
488 ret = regmap_update_bits(smb->regmap, CFG_CURRENT_LIMIT, in smb347_set_current_limits()
501 if (smb->pre_to_fast_voltage) { in smb347_set_voltage_limits()
502 ret = smb->pre_to_fast_voltage; in smb347_set_voltage_limits()
505 ret = clamp_val(ret, 2400000, 3000000) - 2400000; in smb347_set_voltage_limits()
508 ret = regmap_update_bits(smb->regmap, CFG_FLOAT_VOLTAGE, in smb347_set_voltage_limits()
515 if (smb->max_charge_voltage) { in smb347_set_voltage_limits()
516 ret = smb->max_charge_voltage; in smb347_set_voltage_limits()
519 ret = clamp_val(ret, 3500000, 4500000) - 3500000; in smb347_set_voltage_limits()
522 ret = regmap_update_bits(smb->regmap, CFG_FLOAT_VOLTAGE, in smb347_set_voltage_limits()
533 unsigned int id = smb->id; in smb347_set_temp_limits()
538 if (smb->chip_temp_threshold) { in smb347_set_temp_limits()
539 val = smb->chip_temp_threshold; in smb347_set_temp_limits()
542 val = clamp_val(val, 100, 130) - 100; in smb347_set_temp_limits()
545 ret = regmap_update_bits(smb->regmap, CFG_OTG, in smb347_set_temp_limits()
552 if (smb->soft_cold_temp_limit != SMB3XX_TEMP_USE_DEFAULT) { in smb347_set_temp_limits()
553 val = smb->soft_cold_temp_limit; in smb347_set_temp_limits()
560 ret = regmap_update_bits(smb->regmap, CFG_TEMP_LIMIT, in smb347_set_temp_limits()
569 if (smb->soft_hot_temp_limit != SMB3XX_TEMP_USE_DEFAULT) { in smb347_set_temp_limits()
570 val = smb->soft_hot_temp_limit; in smb347_set_temp_limits()
572 val = clamp_val(val, 40, 55) - 40; in smb347_set_temp_limits()
575 ret = regmap_update_bits(smb->regmap, CFG_TEMP_LIMIT, in smb347_set_temp_limits()
584 if (smb->hard_cold_temp_limit != SMB3XX_TEMP_USE_DEFAULT) { in smb347_set_temp_limits()
585 val = smb->hard_cold_temp_limit; in smb347_set_temp_limits()
587 val = clamp_val(val, -5, 10) + 5; in smb347_set_temp_limits()
592 ret = regmap_update_bits(smb->regmap, CFG_TEMP_LIMIT, in smb347_set_temp_limits()
601 if (smb->hard_hot_temp_limit != SMB3XX_TEMP_USE_DEFAULT) { in smb347_set_temp_limits()
602 val = smb->hard_hot_temp_limit; in smb347_set_temp_limits()
604 val = clamp_val(val, 50, 65) - 50; in smb347_set_temp_limits()
607 ret = regmap_update_bits(smb->regmap, CFG_TEMP_LIMIT, in smb347_set_temp_limits()
621 * current and/or voltage depending on the configuration. in smb347_set_temp_limits()
623 * When hard limit is hit, the device will suspend charging in smb347_set_temp_limits()
627 ret = regmap_update_bits(smb->regmap, CFG_THERM, in smb347_set_temp_limits()
633 if (smb->suspend_on_hard_temp_limit) { in smb347_set_temp_limits()
634 ret = regmap_update_bits(smb->regmap, CFG_SYSOK, in smb347_set_temp_limits()
640 if (smb->soft_temp_limit_compensation != in smb347_set_temp_limits()
642 val = smb->soft_temp_limit_compensation & 0x3; in smb347_set_temp_limits()
644 ret = regmap_update_bits(smb->regmap, CFG_THERM, in smb347_set_temp_limits()
650 ret = regmap_update_bits(smb->regmap, CFG_THERM, in smb347_set_temp_limits()
657 if (smb->charge_current_compensation) { in smb347_set_temp_limits()
659 smb->charge_current_compensation); in smb347_set_temp_limits()
663 ret = regmap_update_bits(smb->regmap, CFG_OTG, in smb347_set_temp_limits()
674 * smb347_set_writable - enables/disables writing to non-volatile registers
677 * You can enable/disable writing to the non-volatile configuration
685 struct i2c_client *client = to_i2c_client(smb->dev); in smb347_set_writable()
688 if (writable && irq_toggle && !smb->irq_unsupported) in smb347_set_writable()
689 disable_irq(client->irq); in smb347_set_writable()
691 ret = regmap_update_bits(smb->regmap, CMD_A, CMD_A_ALLOW_WRITE, in smb347_set_writable()
694 if ((!writable || ret) && irq_toggle && !smb->irq_unsupported) in smb347_set_writable()
695 enable_irq(client->irq); in smb347_set_writable()
730 if (!smb->use_usb) { in smb347_hw_init()
731 ret = regmap_update_bits(smb->regmap, CMD_A, in smb347_hw_init()
739 * If configured by platform data, we enable hardware Auto-OTG in smb347_hw_init()
742 ret = regmap_update_bits(smb->regmap, CFG_OTHER, CFG_OTHER_RID_MASK, in smb347_hw_init()
743 smb->use_usb_otg ? CFG_OTHER_RID_ENABLED_AUTO_OTG : 0); in smb347_hw_init()
748 switch (smb->enable_control) { in smb347_hw_init()
751 ret = regmap_set_bits(smb->regmap, CFG_PIN, CFG_PIN_EN_CTRL); in smb347_hw_init()
761 switch (smb->enable_control) { in smb347_hw_init()
773 ret = regmap_update_bits(smb->regmap, CFG_PIN, CFG_PIN_EN_CTRL_MASK, in smb347_hw_init()
779 ret = regmap_update_bits(smb->regmap, CFG_PIN, CFG_PIN_EN_APSD_IRQ, 0); in smb347_hw_init()
804 ret = regmap_read(smb->regmap, STAT_C, &stat_c); in smb347_interrupt()
806 dev_warn(smb->dev, "reading STAT_C failed\n"); in smb347_interrupt()
810 ret = regmap_read(smb->regmap, IRQSTAT_C, &irqstat_c); in smb347_interrupt()
812 dev_warn(smb->dev, "reading IRQSTAT_C failed\n"); in smb347_interrupt()
816 ret = regmap_read(smb->regmap, IRQSTAT_D, &irqstat_d); in smb347_interrupt()
818 dev_warn(smb->dev, "reading IRQSTAT_D failed\n"); in smb347_interrupt()
822 ret = regmap_read(smb->regmap, IRQSTAT_E, &irqstat_e); in smb347_interrupt()
824 dev_warn(smb->dev, "reading IRQSTAT_E failed\n"); in smb347_interrupt()
833 dev_err(smb->dev, "charging stopped due to charger error\n"); in smb347_interrupt()
834 if (smb->use_mains) in smb347_interrupt()
835 power_supply_changed(smb->mains); in smb347_interrupt()
836 if (smb->use_usb) in smb347_interrupt()
837 power_supply_changed(smb->usb); in smb347_interrupt()
842 * If we reached the termination current the battery is charged and in smb347_interrupt()
848 if (smb->use_mains) in smb347_interrupt()
849 power_supply_changed(smb->mains); in smb347_interrupt()
850 if (smb->use_usb) in smb347_interrupt()
851 power_supply_changed(smb->usb); in smb347_interrupt()
853 dev_dbg(smb->dev, "going to HW maintenance mode\n"); in smb347_interrupt()
862 dev_dbg(smb->dev, "total Charge Timeout INT received\n"); in smb347_interrupt()
865 dev_warn(smb->dev, "charging stopped due to timeout\n"); in smb347_interrupt()
866 if (smb->use_mains) in smb347_interrupt()
867 power_supply_changed(smb->mains); in smb347_interrupt()
868 if (smb->use_usb) in smb347_interrupt()
869 power_supply_changed(smb->usb); in smb347_interrupt()
874 * If we got an under voltage interrupt it means that AC/USB input in smb347_interrupt()
880 if (smb->use_mains) in smb347_interrupt()
881 power_supply_changed(smb->mains); in smb347_interrupt()
882 if (smb->use_usb) in smb347_interrupt()
883 power_supply_changed(smb->usb); in smb347_interrupt()
895 if (smb->irq_unsupported) in smb347_irq_set()
904 * - under voltage in smb347_irq_set()
905 * - termination current reached in smb347_irq_set()
906 * - charger timeout in smb347_irq_set()
907 * - charger error in smb347_irq_set()
909 ret = regmap_update_bits(smb->regmap, CFG_FAULT_IRQ, 0xff, in smb347_irq_set()
914 ret = regmap_update_bits(smb->regmap, CFG_STATUS_IRQ, 0xff, in smb347_irq_set()
920 ret = regmap_update_bits(smb->regmap, CFG_PIN, CFG_PIN_EN_CHARGER_ERROR, in smb347_irq_set()
942 smb->irq_unsupported = true; in smb347_irq_init()
948 if (!client->irq) in smb347_irq_init()
959 ret = regmap_update_bits(smb->regmap, CFG_STAT, in smb347_irq_init()
966 dev_warn(smb->dev, "failed to initialize IRQ: %d\n", ret); in smb347_irq_init()
967 dev_warn(smb->dev, "disabling IRQ support\n"); in smb347_irq_init()
971 ret = devm_request_threaded_irq(smb->dev, client->irq, NULL, in smb347_irq_init()
973 client->name, smb); in smb347_irq_init()
977 smb->irq_unsupported = false; in smb347_irq_init()
987 * Returns the constant charge current programmed
992 unsigned int id = smb->id; in get_const_charge_current()
997 return -ENODATA; in get_const_charge_current()
999 ret = regmap_read(smb->regmap, STAT_B, &v); in get_const_charge_current()
1004 * The current value is composition of FCC and PCC values in get_const_charge_current()
1029 return -ENODATA; in get_const_charge_voltage()
1031 ret = regmap_read(smb->regmap, STAT_A, &v); in get_const_charge_voltage()
1050 if (psy->desc->type == POWER_SUPPLY_TYPE_USB) { in smb347_get_charging_status()
1051 if (!smb->usb_online) in smb347_get_charging_status()
1054 if (!smb->mains_online) in smb347_get_charging_status()
1058 ret = regmap_read(smb->regmap, STAT_C, &val); in smb347_get_charging_status()
1072 * set to charging if battery is in pre-charge, in smb347_get_charging_status()
1107 val->intval = ret; in smb347_get_property_locked()
1111 if (psy->desc->type == POWER_SUPPLY_TYPE_USB) { in smb347_get_property_locked()
1112 if (!smb->usb_online) in smb347_get_property_locked()
1113 return -ENODATA; in smb347_get_property_locked()
1115 if (!smb->mains_online) in smb347_get_property_locked()
1116 return -ENODATA; in smb347_get_property_locked()
1120 * We handle trickle and pre-charging the same, and taper in smb347_get_property_locked()
1125 val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; in smb347_get_property_locked()
1128 val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST; in smb347_get_property_locked()
1131 val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE; in smb347_get_property_locked()
1137 if (psy->desc->type == POWER_SUPPLY_TYPE_USB) in smb347_get_property_locked()
1138 val->intval = smb->usb_online; in smb347_get_property_locked()
1140 val->intval = smb->mains_online; in smb347_get_property_locked()
1147 val->intval = ret; in smb347_get_property_locked()
1154 val->intval = ret; in smb347_get_property_locked()
1158 return -EINVAL; in smb347_get_property_locked()
1169 struct i2c_client *client = to_i2c_client(smb->dev); in smb347_get_property()
1172 if (!smb->irq_unsupported) in smb347_get_property()
1173 disable_irq(client->irq); in smb347_get_property()
1177 if (!smb->irq_unsupported) in smb347_get_property()
1178 enable_irq(client->irq); in smb347_get_property()
1236 struct device *dev = smb->dev; in smb347_dt_parse_dev_info()
1238 smb->soft_temp_limit_compensation = in smb347_dt_parse_dev_info()
1242 * pre-initialize the values. See smb347_get_battery_info() below. in smb347_dt_parse_dev_info()
1244 smb->soft_cold_temp_limit = SMB3XX_TEMP_USE_DEFAULT; in smb347_dt_parse_dev_info()
1245 smb->hard_cold_temp_limit = SMB3XX_TEMP_USE_DEFAULT; in smb347_dt_parse_dev_info()
1246 smb->soft_hot_temp_limit = SMB3XX_TEMP_USE_DEFAULT; in smb347_dt_parse_dev_info()
1247 smb->hard_hot_temp_limit = SMB3XX_TEMP_USE_DEFAULT; in smb347_dt_parse_dev_info()
1250 device_property_read_u32(dev, "summit,fast-voltage-threshold-microvolt", in smb347_dt_parse_dev_info()
1251 &smb->pre_to_fast_voltage); in smb347_dt_parse_dev_info()
1252 device_property_read_u32(dev, "summit,mains-current-limit-microamp", in smb347_dt_parse_dev_info()
1253 &smb->mains_current_limit); in smb347_dt_parse_dev_info()
1254 device_property_read_u32(dev, "summit,usb-current-limit-microamp", in smb347_dt_parse_dev_info()
1255 &smb->usb_hc_current_limit); in smb347_dt_parse_dev_info()
1258 device_property_read_u32(dev, "summit,chip-temperature-threshold-celsius", in smb347_dt_parse_dev_info()
1259 &smb->chip_temp_threshold); in smb347_dt_parse_dev_info()
1260 device_property_read_u32(dev, "summit,soft-compensation-method", in smb347_dt_parse_dev_info()
1261 &smb->soft_temp_limit_compensation); in smb347_dt_parse_dev_info()
1262 device_property_read_u32(dev, "summit,charge-current-compensation-microamp", in smb347_dt_parse_dev_info()
1263 &smb->charge_current_compensation); in smb347_dt_parse_dev_info()
1266 smb->use_mains = device_property_read_bool(dev, "summit,enable-mains-charging"); in smb347_dt_parse_dev_info()
1267 smb->use_usb = device_property_read_bool(dev, "summit,enable-usb-charging"); in smb347_dt_parse_dev_info()
1268 smb->use_usb_otg = device_property_read_bool(dev, "summit,enable-otg-charging"); in smb347_dt_parse_dev_info()
1271 device_property_read_u32(dev, "summit,enable-charge-control", in smb347_dt_parse_dev_info()
1272 &smb->enable_control); in smb347_dt_parse_dev_info()
1278 device_property_read_u32(dev, "summit,inok-polarity", in smb347_dt_parse_dev_info()
1279 &smb->inok_polarity); in smb347_dt_parse_dev_info()
1288 if (smb->mains) in smb347_get_battery_info()
1289 supply = smb->mains; in smb347_get_battery_info()
1291 supply = smb->usb; in smb347_get_battery_info()
1294 if (err == -ENXIO || err == -ENODEV) in smb347_get_battery_info()
1299 if (info->constant_charge_current_max_ua != -EINVAL) in smb347_get_battery_info()
1300 smb->max_charge_current = info->constant_charge_current_max_ua; in smb347_get_battery_info()
1302 if (info->constant_charge_voltage_max_uv != -EINVAL) in smb347_get_battery_info()
1303 smb->max_charge_voltage = info->constant_charge_voltage_max_uv; in smb347_get_battery_info()
1305 if (info->precharge_current_ua != -EINVAL) in smb347_get_battery_info()
1306 smb->pre_charge_current = info->precharge_current_ua; in smb347_get_battery_info()
1308 if (info->charge_term_current_ua != -EINVAL) in smb347_get_battery_info()
1309 smb->termination_current = info->charge_term_current_ua; in smb347_get_battery_info()
1311 if (info->temp_alert_min != INT_MIN) in smb347_get_battery_info()
1312 smb->soft_cold_temp_limit = info->temp_alert_min; in smb347_get_battery_info()
1314 if (info->temp_alert_max != INT_MAX) in smb347_get_battery_info()
1315 smb->soft_hot_temp_limit = info->temp_alert_max; in smb347_get_battery_info()
1317 if (info->temp_min != INT_MIN) in smb347_get_battery_info()
1318 smb->hard_cold_temp_limit = info->temp_min; in smb347_get_battery_info()
1320 if (info->temp_max != INT_MAX) in smb347_get_battery_info()
1321 smb->hard_hot_temp_limit = info->temp_max; in smb347_get_battery_info()
1324 if (smb->hard_cold_temp_limit != SMB3XX_TEMP_USE_DEFAULT || in smb347_get_battery_info()
1325 smb->hard_hot_temp_limit != SMB3XX_TEMP_USE_DEFAULT) in smb347_get_battery_info()
1326 smb->suspend_on_hard_temp_limit = true; in smb347_get_battery_info()
1337 ret = regmap_read(smb->regmap, CFG_OTG, &val); in smb347_usb_vbus_get_current_limit()
1343 * access to the datasheet, assume it's limit-enable. in smb347_usb_vbus_get_current_limit()
1362 ret = regmap_update_bits(smb->regmap, CFG_OTG, mask, val); in smb347_usb_vbus_set_new_current_limit()
1364 dev_err(smb->dev, "failed to change USB current limit\n"); in smb347_usb_vbus_set_new_current_limit()
1396 if (device_property_read_bool(&rdev->dev, "summit,needs-inok-toggle")) { in smb347_usb_vbus_regulator_enable()
1399 if (smb->inok_polarity == SMB3XX_SYSOK_INOK_ACTIVE_LOW) in smb347_usb_vbus_regulator_enable()
1406 ret = regmap_update_bits(smb->regmap, CFG_SYSOK, in smb347_usb_vbus_regulator_enable()
1409 dev_err(smb->dev, "failed to disable INOK\n"); in smb347_usb_vbus_regulator_enable()
1416 dev_err(smb->dev, "failed to get USB VBUS current limit\n"); in smb347_usb_vbus_regulator_enable()
1424 dev_err(smb->dev, "failed to preset USB VBUS current limit\n"); in smb347_usb_vbus_regulator_enable()
1428 ret = regmap_set_bits(smb->regmap, CMD_A, CMD_A_OTG_ENABLED); in smb347_usb_vbus_regulator_enable()
1430 dev_err(smb->dev, "failed to enable USB VBUS\n"); in smb347_usb_vbus_regulator_enable()
1434 smb->usb_vbus_enabled = true; in smb347_usb_vbus_regulator_enable()
1438 dev_err(smb->dev, "failed to restore USB VBUS current limit\n"); in smb347_usb_vbus_regulator_enable()
1456 ret = regmap_clear_bits(smb->regmap, CMD_A, CMD_A_OTG_ENABLED); in smb347_usb_vbus_regulator_disable()
1458 dev_err(smb->dev, "failed to disable USB VBUS\n"); in smb347_usb_vbus_regulator_disable()
1462 smb->usb_vbus_enabled = false; in smb347_usb_vbus_regulator_disable()
1464 if (device_property_read_bool(&rdev->dev, "summit,needs-inok-toggle")) { in smb347_usb_vbus_regulator_disable()
1467 if (smb->inok_polarity == SMB3XX_SYSOK_INOK_ACTIVE_HIGH) in smb347_usb_vbus_regulator_disable()
1470 ret = regmap_update_bits(smb->regmap, CFG_SYSOK, in smb347_usb_vbus_regulator_disable()
1473 dev_err(smb->dev, "failed to enable INOK\n"); in smb347_usb_vbus_regulator_disable()
1503 .name = "smb347-mains",
1511 .name = "smb347-usb",
1519 .name = "smb347-usb-vbus",
1520 .of_match = of_match_ptr("usb-vbus"),
1536 struct device *dev = &client->dev; in smb347_probe()
1542 return -ENOMEM; in smb347_probe()
1543 smb->dev = &client->dev; in smb347_probe()
1544 smb->id = id->driver_data; in smb347_probe()
1548 if (!smb->use_mains && !smb->use_usb) in smb347_probe()
1549 return -EINVAL; in smb347_probe()
1551 smb->regmap = devm_regmap_init_i2c(client, &smb347_regmap); in smb347_probe()
1552 if (IS_ERR(smb->regmap)) in smb347_probe()
1553 return PTR_ERR(smb->regmap); in smb347_probe()
1556 mains_usb_cfg.of_node = dev->of_node; in smb347_probe()
1557 if (smb->use_mains) { in smb347_probe()
1558 smb->mains = devm_power_supply_register(dev, &smb347_mains_desc, in smb347_probe()
1560 if (IS_ERR(smb->mains)) in smb347_probe()
1561 return PTR_ERR(smb->mains); in smb347_probe()
1564 if (smb->use_usb) { in smb347_probe()
1565 smb->usb = devm_power_supply_register(dev, &smb347_usb_desc, in smb347_probe()
1567 if (IS_ERR(smb->usb)) in smb347_probe()
1568 return PTR_ERR(smb->usb); in smb347_probe()
1585 usb_rdev_cfg.regmap = smb->regmap; in smb347_probe()
1587 smb->usb_rdev = devm_regulator_register(dev, in smb347_probe()
1590 if (IS_ERR(smb->usb_rdev)) { in smb347_probe()
1592 return PTR_ERR(smb->usb_rdev); in smb347_probe()
1602 smb347_usb_vbus_regulator_disable(smb->usb_rdev); in smb347_remove()