Lines Matching +full:product +full:- +full:files
1 // SPDX-License-Identifier: GPL-2.0+
3 * Fast-charge control for Apple "MFi" devices
8 /* Standard include files */
15 MODULE_DESCRIPTION("Fast-charge control for Apple \"MFi\" devices");
23 /* The product ID is defined as starting with 0x12nn, as per the
30 * ■ Product ID: 0x12nn
43 /* Driver-local specific stuff */
58 if (mfi->charge_type == val->intval) { in apple_mfi_fc_set_charge_type()
59 dev_dbg(&mfi->udev->dev, "charge type %d already set\n", in apple_mfi_fc_set_charge_type()
60 mfi->charge_type); in apple_mfi_fc_set_charge_type()
64 switch (val->intval) { in apple_mfi_fc_set_charge_type()
72 return -EINVAL; in apple_mfi_fc_set_charge_type()
76 retval = usb_control_msg(mfi->udev, usb_sndctrlpipe(mfi->udev, 0), in apple_mfi_fc_set_charge_type()
83 dev_dbg(&mfi->udev->dev, "retval = %d\n", retval); in apple_mfi_fc_set_charge_type()
87 mfi->charge_type = val->intval; in apple_mfi_fc_set_charge_type()
98 dev_dbg(&mfi->udev->dev, "prop: %d\n", psp); in apple_mfi_fc_get_property()
102 val->intval = mfi->charge_type; in apple_mfi_fc_get_property()
105 val->intval = POWER_SUPPLY_SCOPE_DEVICE; in apple_mfi_fc_get_property()
108 return -ENODATA; in apple_mfi_fc_get_property()
121 dev_dbg(&mfi->udev->dev, "prop: %d\n", psp); in apple_mfi_fc_set_property()
123 ret = pm_runtime_get_sync(&mfi->udev->dev); in apple_mfi_fc_set_property()
125 pm_runtime_put_noidle(&mfi->udev->dev); in apple_mfi_fc_set_property()
134 ret = -EINVAL; in apple_mfi_fc_set_property()
137 pm_runtime_mark_last_busy(&mfi->udev->dev); in apple_mfi_fc_set_property()
138 pm_runtime_put_autosuspend(&mfi->udev->dev); in apple_mfi_fc_set_property()
173 idProduct = le16_to_cpu(udev->descriptor.idProduct); in mfi_fc_match()
186 return -ENODEV; in mfi_fc_probe()
190 return -ENOMEM; in mfi_fc_probe()
192 battery_name = kasprintf(GFP_KERNEL, "apple_mfi_fastcharge_%d-%d", in mfi_fc_probe()
193 udev->bus->busnum, udev->devnum); in mfi_fc_probe()
195 err = -ENOMEM; in mfi_fc_probe()
199 mfi->battery_desc = apple_mfi_fc_desc; in mfi_fc_probe()
200 mfi->battery_desc.name = battery_name; in mfi_fc_probe()
204 mfi->charge_type = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; in mfi_fc_probe()
205 mfi->battery = power_supply_register(&udev->dev, in mfi_fc_probe()
206 &mfi->battery_desc, in mfi_fc_probe()
208 if (IS_ERR(mfi->battery)) { in mfi_fc_probe()
209 dev_err(&udev->dev, "Can't register battery\n"); in mfi_fc_probe()
210 err = PTR_ERR(mfi->battery); in mfi_fc_probe()
214 mfi->udev = usb_get_dev(udev); in mfi_fc_probe()
215 dev_set_drvdata(&udev->dev, mfi); in mfi_fc_probe()
230 mfi = dev_get_drvdata(&udev->dev); in mfi_fc_disconnect()
231 if (mfi->battery) in mfi_fc_disconnect()
232 power_supply_unregister(mfi->battery); in mfi_fc_disconnect()
233 kfree(mfi->battery_desc.name); in mfi_fc_disconnect()
234 dev_set_drvdata(&udev->dev, NULL); in mfi_fc_disconnect()
235 usb_put_dev(mfi->udev); in mfi_fc_disconnect()
240 .name = "apple-mfi-fastcharge",