17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/slab.h>
21 #include <linux/types.h>
22 #include <linux/device.h>
46 int charging_start = 1;
53 }
else if (ma >= 500) {
56 }
else if (ma >= 100) {
68 dev_err(pcf->
dev,
"error setting usb curlim to %d mA\n", ma);
83 if (mbc->
pcf->pdata->charger_reference_current_ma) {
84 mbcc5 = (ma << 8) / mbc->
pcf->pdata->charger_reference_current_ma;
163 return sprintf(buf,
"%d\n", chgmod);
184 return sprintf(buf,
"%u\n", ma);
212 if (!mbc->
pcf->pdata->charger_reference_current_ma)
215 ma = (mbc->
pcf->pdata->charger_reference_current_ma * mbcc5) >> 8;
217 return sprintf(buf,
"%u\n", ma);
228 if (!mbc->
pcf->pdata->charger_reference_current_ma)
235 mbcc5 = (ma << 8) / mbc->
pcf->pdata->charger_reference_current_ma;
250 static struct attribute *pcf50633_mbc_sysfs_entries[] = {
251 &dev_attr_chgmode.attr,
252 &dev_attr_usb_curlim.attr,
253 &dev_attr_chg_curlim.attr,
259 .attrs = pcf50633_mbc_sysfs_entries,
263 pcf50633_mbc_irq_handler(
int irq,
void *
data)
285 if (mbc->
pcf->pdata->mbc_event_callback)
286 mbc->
pcf->pdata->mbc_event_callback(mbc->
pcf, irq);
289 static int adapter_get_property(
struct power_supply *psy,
354 static const u8 mbc_irq_handlers[] = {
380 platform_set_drvdata(pdev, mbc);
381 mbc->
pcf = dev_to_pcf50633(pdev->
dev.parent);
384 for (i = 0; i <
ARRAY_SIZE(mbc_irq_handlers); i++)
386 pcf50633_mbc_irq_handler, mbc);
391 mbc->
adapter.properties = power_props;
393 mbc->
adapter.get_property = &adapter_get_property;
394 mbc->
adapter.supplied_to = mbc->
pcf->pdata->batteries;
395 mbc->
adapter.num_supplicants = mbc->
pcf->pdata->num_batteries;
397 mbc->
usb.name =
"usb";
399 mbc->
usb.properties = power_props;
401 mbc->
usb.get_property = usb_get_property;
402 mbc->
usb.supplied_to = mbc->
pcf->pdata->batteries;
403 mbc->
usb.num_supplicants = mbc->
pcf->pdata->num_batteries;
407 mbc->
ac.properties = power_props;
409 mbc->
ac.get_property = ac_get_property;
410 mbc->
ac.supplied_to = mbc->
pcf->pdata->batteries;
411 mbc->
ac.num_supplicants = mbc->
pcf->pdata->num_batteries;
415 dev_err(mbc->
pcf->dev,
"failed to register adapter\n");
422 dev_err(mbc->
pcf->dev,
"failed to register usb\n");
430 dev_err(mbc->
pcf->dev,
"failed to register ac\n");
439 dev_err(mbc->
pcf->dev,
"failed to create sysfs entries\n");
456 for (i = 0; i <
ARRAY_SIZE(mbc_irq_handlers); i++)
471 .name =
"pcf50633-mbc",
473 .probe = pcf50633_mbc_probe,