Lines Matching refs:mbc
43 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev); in pcf50633_mbc_usb_curlim_set() local
83 if (mbc->pcf->pdata->charger_reference_current_ma) { in pcf50633_mbc_usb_curlim_set()
84 mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma; in pcf50633_mbc_usb_curlim_set()
87 pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5); in pcf50633_mbc_usb_curlim_set()
90 mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2); in pcf50633_mbc_usb_curlim_set()
107 power_supply_changed(&mbc->usb); in pcf50633_mbc_usb_curlim_set()
115 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev); in pcf50633_mbc_get_status() local
119 if (!mbc) in pcf50633_mbc_get_status()
122 chgmod = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2) in pcf50633_mbc_get_status()
125 if (mbc->usb_online) in pcf50633_mbc_get_status()
132 if (mbc->adapter_online) in pcf50633_mbc_get_status()
146 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev); in pcf50633_mbc_get_usb_online_status() local
148 if (!mbc) in pcf50633_mbc_get_usb_online_status()
151 return mbc->usb_online; in pcf50633_mbc_get_usb_online_status()
158 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in show_chgmode() local
160 u8 mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2); in show_chgmode()
170 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in show_usblim() local
171 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) & in show_usblim()
190 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in set_usblim() local
198 pcf50633_mbc_usb_curlim_set(mbc->pcf, ma); in set_usblim()
208 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in show_chglim() local
209 u8 mbcc5 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC5); in show_chglim()
212 if (!mbc->pcf->pdata->charger_reference_current_ma) in show_chglim()
215 ma = (mbc->pcf->pdata->charger_reference_current_ma * mbcc5) >> 8; in show_chglim()
223 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in set_chglim() local
228 if (!mbc->pcf->pdata->charger_reference_current_ma) in set_chglim()
235 mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma; in set_chglim()
238 pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5); in set_chglim()
265 struct pcf50633_mbc *mbc = data; in pcf50633_mbc_irq_handler() local
269 mbc->usb_online = 1; in pcf50633_mbc_irq_handler()
271 mbc->usb_online = 0; in pcf50633_mbc_irq_handler()
272 pcf50633_mbc_usb_curlim_set(mbc->pcf, 0); in pcf50633_mbc_irq_handler()
277 mbc->adapter_online = 1; in pcf50633_mbc_irq_handler()
279 mbc->adapter_online = 0; in pcf50633_mbc_irq_handler()
281 power_supply_changed(&mbc->ac); in pcf50633_mbc_irq_handler()
282 power_supply_changed(&mbc->usb); in pcf50633_mbc_irq_handler()
283 power_supply_changed(&mbc->adapter); in pcf50633_mbc_irq_handler()
285 if (mbc->pcf->pdata->mbc_event_callback) in pcf50633_mbc_irq_handler()
286 mbc->pcf->pdata->mbc_event_callback(mbc->pcf, irq); in pcf50633_mbc_irq_handler()
293 struct pcf50633_mbc *mbc = container_of(psy, in adapter_get_property() local
299 val->intval = mbc->adapter_online; in adapter_get_property()
312 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb); in usb_get_property() local
314 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) & in usb_get_property()
319 val->intval = mbc->usb_online && in usb_get_property()
333 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, ac); in ac_get_property() local
335 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) & in ac_get_property()
340 val->intval = mbc->usb_online && in ac_get_property()
371 struct pcf50633_mbc *mbc; in pcf50633_mbc_probe() local
376 mbc = devm_kzalloc(&pdev->dev, sizeof(*mbc), GFP_KERNEL); in pcf50633_mbc_probe()
377 if (!mbc) in pcf50633_mbc_probe()
380 platform_set_drvdata(pdev, mbc); in pcf50633_mbc_probe()
381 mbc->pcf = dev_to_pcf50633(pdev->dev.parent); in pcf50633_mbc_probe()
385 pcf50633_register_irq(mbc->pcf, mbc_irq_handlers[i], in pcf50633_mbc_probe()
386 pcf50633_mbc_irq_handler, mbc); in pcf50633_mbc_probe()
389 mbc->adapter.name = "adapter"; in pcf50633_mbc_probe()
390 mbc->adapter.type = POWER_SUPPLY_TYPE_MAINS; in pcf50633_mbc_probe()
391 mbc->adapter.properties = power_props; in pcf50633_mbc_probe()
392 mbc->adapter.num_properties = ARRAY_SIZE(power_props); in pcf50633_mbc_probe()
393 mbc->adapter.get_property = &adapter_get_property; in pcf50633_mbc_probe()
394 mbc->adapter.supplied_to = mbc->pcf->pdata->batteries; in pcf50633_mbc_probe()
395 mbc->adapter.num_supplicants = mbc->pcf->pdata->num_batteries; in pcf50633_mbc_probe()
397 mbc->usb.name = "usb"; in pcf50633_mbc_probe()
398 mbc->usb.type = POWER_SUPPLY_TYPE_USB; in pcf50633_mbc_probe()
399 mbc->usb.properties = power_props; in pcf50633_mbc_probe()
400 mbc->usb.num_properties = ARRAY_SIZE(power_props); in pcf50633_mbc_probe()
401 mbc->usb.get_property = usb_get_property; in pcf50633_mbc_probe()
402 mbc->usb.supplied_to = mbc->pcf->pdata->batteries; in pcf50633_mbc_probe()
403 mbc->usb.num_supplicants = mbc->pcf->pdata->num_batteries; in pcf50633_mbc_probe()
405 mbc->ac.name = "ac"; in pcf50633_mbc_probe()
406 mbc->ac.type = POWER_SUPPLY_TYPE_MAINS; in pcf50633_mbc_probe()
407 mbc->ac.properties = power_props; in pcf50633_mbc_probe()
408 mbc->ac.num_properties = ARRAY_SIZE(power_props); in pcf50633_mbc_probe()
409 mbc->ac.get_property = ac_get_property; in pcf50633_mbc_probe()
410 mbc->ac.supplied_to = mbc->pcf->pdata->batteries; in pcf50633_mbc_probe()
411 mbc->ac.num_supplicants = mbc->pcf->pdata->num_batteries; in pcf50633_mbc_probe()
413 ret = power_supply_register(&pdev->dev, &mbc->adapter); in pcf50633_mbc_probe()
415 dev_err(mbc->pcf->dev, "failed to register adapter\n"); in pcf50633_mbc_probe()
419 ret = power_supply_register(&pdev->dev, &mbc->usb); in pcf50633_mbc_probe()
421 dev_err(mbc->pcf->dev, "failed to register usb\n"); in pcf50633_mbc_probe()
422 power_supply_unregister(&mbc->adapter); in pcf50633_mbc_probe()
426 ret = power_supply_register(&pdev->dev, &mbc->ac); in pcf50633_mbc_probe()
428 dev_err(mbc->pcf->dev, "failed to register ac\n"); in pcf50633_mbc_probe()
429 power_supply_unregister(&mbc->adapter); in pcf50633_mbc_probe()
430 power_supply_unregister(&mbc->usb); in pcf50633_mbc_probe()
436 dev_err(mbc->pcf->dev, "failed to create sysfs entries\n"); in pcf50633_mbc_probe()
438 mbcs1 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS1); in pcf50633_mbc_probe()
440 pcf50633_mbc_irq_handler(PCF50633_IRQ_USBINS, mbc); in pcf50633_mbc_probe()
442 pcf50633_mbc_irq_handler(PCF50633_IRQ_ADPINS, mbc); in pcf50633_mbc_probe()
449 struct pcf50633_mbc *mbc = platform_get_drvdata(pdev); in pcf50633_mbc_remove() local
454 pcf50633_free_irq(mbc->pcf, mbc_irq_handlers[i]); in pcf50633_mbc_remove()
457 power_supply_unregister(&mbc->usb); in pcf50633_mbc_remove()
458 power_supply_unregister(&mbc->adapter); in pcf50633_mbc_remove()
459 power_supply_unregister(&mbc->ac); in pcf50633_mbc_remove()