Lines Matching full:charger
5 * Charger driver for AB8500
37 /* Charger constants */
92 /* Lowest charger voltage is 3.39V -> 0x4E */
105 /*External charger control*/
216 * struct ab8500_charger - ab8500 Charger device information
221 * @ac_conn: This will be true when the AC charger has been plugged
223 * charger is enabled
225 * charger is enabled
231 * @invalid_charger_detect_state State when forcing AB to use invalid charger
236 * @adc_main_charger_v ADC channel for main charger voltage
237 * @adc_main_charger_c ADC channel for main charger current
238 * @adc_vbus_v ADC channel for USB charger voltage
239 * @adc_usb_charger_c ADC channel for USB charger current
243 * @max_usb_in_curr: Max USB charger input current
244 * @ac_chg: AC charger power supply
245 * @usb_chg: USB charger power supply
246 * @ac: Structure that holds the AC charger properties
247 * @usb: Structure that holds the USB charger properties
254 * @check_usbchgnotok_work: Work for checking USB charger not ok status
255 * @kick_wd_work: Work for kicking the charger watchdog in case
257 * @ac_charger_attached_work: Work for checking if AC charger is still
259 * @usb_charger_attached_work: Work for checking if USB charger is still
261 * @ac_work: Work for checking AC charger connection
346 * should always be disabled when no charger is connected.
461 * ab8500_charger_get_ac_voltage() - get ac charger voltage
464 * Returns ac charger voltage (on success)
470 /* Only measure voltage if the charger is connected */ in ab8500_charger_get_ac_voltage()
482 * ab8500_charger_ac_cv() - check if the main charger is in CV mode
485 * Returns ac charger CV mode (on success) else error code
492 /* Only check CV mode if the charger is online */ in ab8500_charger_ac_cv()
521 /* Only measure voltage if the charger is connected */ in ab8500_charger_get_vbus_voltage()
533 * ab8500_charger_get_usb_current() - get usb charger current
536 * This function returns the usb charger current.
543 /* Only measure current if the charger is online */ in ab8500_charger_get_usb_current()
555 * ab8500_charger_get_ac_current() - get ac charger current
558 * This function returns the ac charger current.
565 /* Only measure current if the charger is online */ in ab8500_charger_get_ac_current()
577 * ab8500_charger_usb_cv() - check if the usb charger is in CV mode
580 * Returns ac charger CV mode (on success) else error code
587 /* Only check CV mode if the charger is online */ in ab8500_charger_usb_cv()
612 * Returns the type of charger connected.
616 * interrupts of the charger detection
630 /* Check for AC charger */ in ab8500_charger_detect_chargers()
641 /* Check for USB charger */ in ab8500_charger_detect_chargers()
647 * charger was connected. Try waiting a little in ab8500_charger_detect_chargers()
713 * Dedicated charger level minus maximum current accessory in ab8500_charger_max_usb_curr()
722 * Dedicated charger level minus 120mA (20mA for ACA and in ab8500_charger_max_usb_curr()
746 dev_dbg(di->dev, "USB Type - Legacy charger.\n"); in ab8500_charger_max_usb_curr()
905 * This array maps the raw hex value to charger voltage used by the AB8500
1090 * @reg: select what charger register to check
1093 * Checks if charger source has not collapsed. If it has, further stepping
1106 * ab8500_charger_set_current() - set charger current
1108 * @ich: charger current, in mA
1109 * @reg: select what charger register to set
1111 * Set charger current.
1112 * There is no state machine in the AB to step up/down the charger
1115 * this charger current step-up/down here.
1186 dev_dbg(di->dev, "%s set charger current: %d mA for reg: 0x%02x\n", in ab8500_charger_set_current()
1234 * @ich_in: charger input current limit
1277 * ab8500_charger_set_main_in_curr() - set main charger input current
1279 * @ich_in: input charger current, in mA
1281 * Set main charger input current.
1292 * ab8500_charger_set_output_curr() - set charger output current
1294 * @ich_out: output charger current, in mA
1296 * Set charger output current.
1359 static int ab8500_charger_ac_en(struct ux500_charger *charger, in ab8500_charger_ac_en() argument
1368 struct ab8500_charger *di = to_ab8500_charger_ac_device_info(charger); in ab8500_charger_ac_en()
1373 dev_err(di->dev, "AC charger not connected\n"); in ab8500_charger_ac_en()
1385 * there is a charger enabled. Normally the VDD ADC supply in ab8500_charger_ac_en()
1406 "Charger voltage or current too high, " in ab8500_charger_ac_en()
1418 /* MainChInputCurr: current that can be drawn from the charger*/ in ab8500_charger_ac_en()
1439 /* Enable Main Charger */ in ab8500_charger_ac_en()
1459 * kick the charger watchdog even when no charger is in ab8500_charger_ac_en()
1460 * connected. This is only valid once the AC charger in ab8500_charger_ac_en()
1463 * by the charger driver when the AC charger in ab8500_charger_ac_en()
1531 * @ich_out: charger output current
1536 static int ab8500_charger_usb_en(struct ux500_charger *charger, in ab8500_charger_usb_en() argument
1544 struct ab8500_charger *di = to_ab8500_charger_usb_device_info(charger); in ab8500_charger_usb_en()
1549 dev_err(di->dev, "USB charger not connected\n"); in ab8500_charger_usb_en()
1558 * there is a charger enabled. Normally the VDD ADC supply in ab8500_charger_usb_en()
1580 "Charger voltage or current too high, " in ab8500_charger_usb_en()
1599 /* Enable USB Charger */ in ab8500_charger_usb_en()
1690 /*Toggle External charger control pin*/ in ab8500_external_charger_prepare()
1710 * @charger: pointer to the ux500_charger structure
1712 * @iset: charger output current
1714 * Check if the VBUS charger has been disconnected and reconnected without
1717 static int ab8500_charger_usb_check_enable(struct ux500_charger *charger, in ab8500_charger_usb_check_enable() argument
1723 struct ab8500_charger *di = to_ab8500_charger_usb_device_info(charger); in ab8500_charger_usb_check_enable()
1734 dev_dbg(di->dev, "USB charger ctrl: 0x%02x\n", usbch_ctrl1); in ab8500_charger_usb_check_enable()
1749 dev_err(di->dev, "Failed to enable VBUS charger %d\n", in ab8500_charger_usb_check_enable()
1759 * @charger: pointer to the ux500_charger structure
1761 * @iset: charger output current
1763 * Check if the AC charger has been disconnected and reconnected without
1766 static int ab8500_charger_ac_check_enable(struct ux500_charger *charger, in ab8500_charger_ac_check_enable() argument
1772 struct ab8500_charger *di = to_ab8500_charger_ac_device_info(charger); in ab8500_charger_ac_check_enable()
1783 dev_dbg(di->dev, "AC charger ctrl: 0x%02x\n", mainch_ctrl1); in ab8500_charger_ac_check_enable()
1799 dev_err(di->dev, "failed to enable AC charger %d\n", in ab8500_charger_ac_check_enable()
1808 * ab8500_charger_watchdog_kick() - kick charger watchdog
1811 * Kick charger watchdog
1814 static int ab8500_charger_watchdog_kick(struct ux500_charger *charger) in ab8500_charger_watchdog_kick() argument
1819 if (charger->psy->desc->type == POWER_SUPPLY_TYPE_MAINS) in ab8500_charger_watchdog_kick()
1820 di = to_ab8500_charger_ac_device_info(charger); in ab8500_charger_watchdog_kick()
1821 else if (charger->psy->desc->type == POWER_SUPPLY_TYPE_USB) in ab8500_charger_watchdog_kick()
1822 di = to_ab8500_charger_usb_device_info(charger); in ab8500_charger_watchdog_kick()
1835 * ab8500_charger_update_charger_current() - update charger current
1838 * Update the charger output current for the specified charger
1841 static int ab8500_charger_update_charger_current(struct ux500_charger *charger, in ab8500_charger_update_charger_current() argument
1847 if (charger->psy->desc->type == POWER_SUPPLY_TYPE_MAINS) in ab8500_charger_update_charger_current()
1848 di = to_ab8500_charger_ac_device_info(charger); in ab8500_charger_update_charger_current()
1849 else if (charger->psy->desc->type == POWER_SUPPLY_TYPE_USB) in ab8500_charger_update_charger_current()
1850 di = to_ab8500_charger_usb_device_info(charger); in ab8500_charger_update_charger_current()
1923 * charger when charging with at some specific levels. This issue is only valid
1967 * ab8500_charger_check_hw_failure_work() - check main charger failure
1970 * Work queue function for checking the main charger status
2017 * Work queue function for kicking the charger watchdog.
2020 * logic. That means we have to continuously kick the charger
2021 * watchdog even when no charger is connected. This is only
2022 * valid once the AC charger has been enabled. This is
2024 * watchdog have to be kicked by the charger driver
2025 * when the AC charger is disabled
2045 * ab8500_charger_ac_work() - work to get and set main charger status
2048 * Work queue function for checking the main charger status
2059 * synchronously, we have the check if the main charger is in ab8500_charger_ac_work()
2292 "Invalid charger detected, state= 0\n"); in ab8500_charger_usb_link_status_work()
2293 /*Enable charger*/ in ab8500_charger_usb_link_status_work()
2297 /*Enable charger detection*/ in ab8500_charger_usb_link_status_work()
2308 "Invalid charger detected, state= 1\n"); in ab8500_charger_usb_link_status_work()
2309 /*Stop charger detection*/ in ab8500_charger_usb_link_status_work()
2343 /* No valid charger type detected */ in ab8500_charger_usb_link_status_work()
2352 "Potential Legacy Charger device. " in ab8500_charger_usb_link_status_work()
2440 * Work queue function for checking the USB charger Not OK status
2535 * ab8500_charger_mainchunplugdet_handler() - main charger unplugged
2545 dev_dbg(di->dev, "Main charger unplugged\n"); in ab8500_charger_mainchunplugdet_handler()
2556 * ab8500_charger_mainchplugdet_handler() - main charger plugged
2566 dev_dbg(di->dev, "Main charger plugged\n"); in ab8500_charger_mainchplugdet_handler()
2580 * ab8500_charger_mainextchnotok_handler() - main charger not ok
2590 dev_dbg(di->dev, "Main charger not ok\n"); in ab8500_charger_mainextchnotok_handler()
2601 * ab8500_charger_mainchthprotr_handler() - Die temp is above main charger
2613 "Die temp above Main charger thermal protection threshold\n"); in ab8500_charger_mainchthprotr_handler()
2620 * ab8500_charger_mainchthprotf_handler() - Die temp is below main charger
2632 "Die temp ok for Main charger thermal protection threshold\n"); in ab8500_charger_mainchthprotf_handler()
2740 * ab8500_charger_usbchthprotr_handler() - Die temp is above usb charger
2752 "Die temp above USB charger thermal protection threshold\n"); in ab8500_charger_usbchthprotr_handler()
2759 * ab8500_charger_usbchthprotf_handler() - Die temp is below usb charger
2771 "Die temp ok for USB charger thermal protection threshold\n"); in ab8500_charger_usbchthprotf_handler()
2778 * ab8500_charger_usbchargernotokr_handler() - USB charger not ok detected
2788 dev_dbg(di->dev, "Not allowed USB charger detected\n"); in ab8500_charger_usbchargernotokr_handler()
2795 * ab8500_charger_chwdexp_handler() - Charger watchdog expired
2805 dev_dbg(di->dev, "Charger watchdog expired\n"); in ab8500_charger_chwdexp_handler()
2808 * The charger that was online when the watchdog expired in ab8500_charger_chwdexp_handler()
2834 dev_dbg(di->dev, "VBUS charger drop ended\n"); in ab8500_charger_vbuschdropend_handler()
2918 * for the AC charger in ab8500_charger_ac_get_property()
2986 * for the USB charger in ab8500_charger_usb_get_property()
3000 * due to too high output current from the USB charger in ab8500_charger_usb_get_property()
3014 * ab8500_charger_init_hw_registers() - Set up charger related registers
3017 * Set up charger OVV, watchdog and maximum voltage registers as well as
3024 /* Setup maximum charger current and voltage for ABB cut2.0 */ in ab8500_charger_init_hw_registers()
3113 dev_err(di->dev, "failed to set charger watchdog timeout\n"); in ab8500_charger_init_hw_registers()
3146 * ab8500 charger driver interrupts and their respective isr
3181 /* TODO: State is fabricate here. See if charger really needs USB in ab8500_charger_usb_notifier_call()
3220 * logic. That means we have to continuously kick the charger in ab8500_charger_resume()
3221 * watchdog even when no charger is connected. This is only in ab8500_charger_resume()
3222 * valid once the AC charger has been enabled. This is in ab8500_charger_resume()
3224 * watchdog have to be kicked by the charger driver in ab8500_charger_resume()
3225 * when the AC charger is disabled in ab8500_charger_resume()
3313 /* Unregister external charger enable notifier */ in ab8500_charger_remove()
3390 dev_err(&pdev->dev, "failed to get ADC main charger voltage\n"); in ab8500_charger_probe()
3398 dev_err(&pdev->dev, "failed to get ADC main charger current\n"); in ab8500_charger_probe()
3405 dev_err(&pdev->dev, "failed to get ADC USB charger voltage\n"); in ab8500_charger_probe()
3413 dev_err(&pdev->dev, "failed to get ADC USB charger current\n"); in ab8500_charger_probe()
3446 /*notifier for external charger enabling*/ in ab8500_charger_probe()
3466 /* Create a work queue for the charger */ in ab8500_charger_probe()
3489 * logic. That means we have to continuously kick the charger in ab8500_charger_probe()
3490 * watchdog even when no charger is connected. This is only in ab8500_charger_probe()
3491 * valid once the AC charger has been enabled. This is in ab8500_charger_probe()
3493 * watchdog have to be kicked by the charger driver in ab8500_charger_probe()
3494 * when the AC charger is disabled in ab8500_charger_probe()
3511 /* Init work for charger detection */ in ab8500_charger_probe()
3526 * is a charger connected to avoid erroneous BTEMP_HIGH/LOW in ab8500_charger_probe()
3544 /* Register AC charger class */ in ab8500_charger_probe()
3550 dev_err(di->dev, "failed to register AC charger\n"); in ab8500_charger_probe()
3556 /* Register USB charger class */ in ab8500_charger_probe()
3562 dev_err(di->dev, "failed to register USB charger\n"); in ab8500_charger_probe()
3581 /* Identify the connected charger types during startup */ in ab8500_charger_probe()
3663 { .compatible = "stericsson,ab8500-charger", },
3673 .name = "ab8500-charger",
3693 MODULE_ALIAS("platform:ab8500-charger");
3694 MODULE_DESCRIPTION("AB8500 charger management driver");