Lines Matching refs:mbc
38 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev); in pcf50633_mbc_usb_curlim_set() local
76 if (mbc->pcf->pdata->charger_reference_current_ma) { in pcf50633_mbc_usb_curlim_set()
77 mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma; in pcf50633_mbc_usb_curlim_set()
80 pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5); in pcf50633_mbc_usb_curlim_set()
83 mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2); in pcf50633_mbc_usb_curlim_set()
100 power_supply_changed(mbc->usb); in pcf50633_mbc_usb_curlim_set()
108 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev); in pcf50633_mbc_get_status() local
112 if (!mbc) in pcf50633_mbc_get_status()
115 chgmod = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2) in pcf50633_mbc_get_status()
118 if (mbc->usb_online) in pcf50633_mbc_get_status()
125 if (mbc->adapter_online) in pcf50633_mbc_get_status()
139 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev); in pcf50633_mbc_get_usb_online_status() local
141 if (!mbc) in pcf50633_mbc_get_usb_online_status()
144 return mbc->usb_online; in pcf50633_mbc_get_usb_online_status()
151 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in show_chgmode() local
153 u8 mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2); in show_chgmode()
163 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in show_usblim() local
164 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) & in show_usblim()
183 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in set_usblim() local
191 pcf50633_mbc_usb_curlim_set(mbc->pcf, ma); in set_usblim()
201 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in show_chglim() local
202 u8 mbcc5 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC5); in show_chglim()
205 if (!mbc->pcf->pdata->charger_reference_current_ma) in show_chglim()
208 ma = (mbc->pcf->pdata->charger_reference_current_ma * mbcc5) >> 8; in show_chglim()
216 struct pcf50633_mbc *mbc = dev_get_drvdata(dev); in set_chglim() local
221 if (!mbc->pcf->pdata->charger_reference_current_ma) in set_chglim()
228 mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma; in set_chglim()
231 pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5); in set_chglim()
255 struct pcf50633_mbc *mbc = data; in pcf50633_mbc_irq_handler() local
259 mbc->usb_online = 1; in pcf50633_mbc_irq_handler()
261 mbc->usb_online = 0; in pcf50633_mbc_irq_handler()
262 pcf50633_mbc_usb_curlim_set(mbc->pcf, 0); in pcf50633_mbc_irq_handler()
267 mbc->adapter_online = 1; in pcf50633_mbc_irq_handler()
269 mbc->adapter_online = 0; in pcf50633_mbc_irq_handler()
271 power_supply_changed(mbc->ac); in pcf50633_mbc_irq_handler()
272 power_supply_changed(mbc->usb); in pcf50633_mbc_irq_handler()
273 power_supply_changed(mbc->adapter); in pcf50633_mbc_irq_handler()
275 if (mbc->pcf->pdata->mbc_event_callback) in pcf50633_mbc_irq_handler()
276 mbc->pcf->pdata->mbc_event_callback(mbc->pcf, irq); in pcf50633_mbc_irq_handler()
283 struct pcf50633_mbc *mbc = power_supply_get_drvdata(psy); in adapter_get_property() local
288 val->intval = mbc->adapter_online; in adapter_get_property()
301 struct pcf50633_mbc *mbc = power_supply_get_drvdata(psy); in usb_get_property() local
303 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) & in usb_get_property()
308 val->intval = mbc->usb_online && in usb_get_property()
322 struct pcf50633_mbc *mbc = power_supply_get_drvdata(psy); in ac_get_property() local
324 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) & in ac_get_property()
329 val->intval = mbc->usb_online && in ac_get_property()
386 struct pcf50633_mbc *mbc; in pcf50633_mbc_probe() local
390 mbc = devm_kzalloc(&pdev->dev, sizeof(*mbc), GFP_KERNEL); in pcf50633_mbc_probe()
391 if (!mbc) in pcf50633_mbc_probe()
394 platform_set_drvdata(pdev, mbc); in pcf50633_mbc_probe()
395 mbc->pcf = dev_to_pcf50633(pdev->dev.parent); in pcf50633_mbc_probe()
399 pcf50633_register_irq(mbc->pcf, mbc_irq_handlers[i], in pcf50633_mbc_probe()
400 pcf50633_mbc_irq_handler, mbc); in pcf50633_mbc_probe()
402 psy_cfg.supplied_to = mbc->pcf->pdata->batteries; in pcf50633_mbc_probe()
403 psy_cfg.num_supplicants = mbc->pcf->pdata->num_batteries; in pcf50633_mbc_probe()
404 psy_cfg.drv_data = mbc; in pcf50633_mbc_probe()
407 mbc->adapter = power_supply_register(&pdev->dev, in pcf50633_mbc_probe()
410 if (IS_ERR(mbc->adapter)) { in pcf50633_mbc_probe()
411 dev_err(mbc->pcf->dev, "failed to register adapter\n"); in pcf50633_mbc_probe()
412 return PTR_ERR(mbc->adapter); in pcf50633_mbc_probe()
418 mbc->usb = power_supply_register(&pdev->dev, &pcf50633_mbc_usb_desc, in pcf50633_mbc_probe()
420 if (IS_ERR(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()
423 return PTR_ERR(mbc->usb); in pcf50633_mbc_probe()
426 mbc->ac = power_supply_register(&pdev->dev, &pcf50633_mbc_ac_desc, in pcf50633_mbc_probe()
428 if (IS_ERR(mbc->ac)) { in pcf50633_mbc_probe()
429 dev_err(mbc->pcf->dev, "failed to register ac\n"); in pcf50633_mbc_probe()
430 power_supply_unregister(mbc->adapter); in pcf50633_mbc_probe()
431 power_supply_unregister(mbc->usb); in pcf50633_mbc_probe()
432 return PTR_ERR(mbc->ac); in pcf50633_mbc_probe()
435 mbcs1 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS1); in pcf50633_mbc_probe()
437 pcf50633_mbc_irq_handler(PCF50633_IRQ_USBINS, mbc); in pcf50633_mbc_probe()
439 pcf50633_mbc_irq_handler(PCF50633_IRQ_ADPINS, mbc); in pcf50633_mbc_probe()
446 struct pcf50633_mbc *mbc = platform_get_drvdata(pdev); in pcf50633_mbc_remove() local
451 pcf50633_free_irq(mbc->pcf, mbc_irq_handlers[i]); in pcf50633_mbc_remove()
453 power_supply_unregister(mbc->usb); in pcf50633_mbc_remove()
454 power_supply_unregister(mbc->adapter); in pcf50633_mbc_remove()
455 power_supply_unregister(mbc->ac); in pcf50633_mbc_remove()