Lines Matching full:charger
5 * Charger driver for AB8500
39 /* Charger constants */
94 /* Lowest charger voltage is 3.39V -> 0x4E */
107 /*External charger control*/
218 * struct ab8500_charger - ab8500 Charger device information
223 * @ac_conn: This will be true when the AC charger has been plugged
225 * charger is enabled
227 * charger is enabled
233 * @invalid_charger_detect_state State when forcing AB to use invalid charger
238 * @adc_main_charger_v ADC channel for main charger voltage
239 * @adc_main_charger_c ADC channel for main charger current
240 * @adc_vbus_v ADC channel for USB charger voltage
241 * @adc_usb_charger_c ADC channel for USB charger current
245 * @max_usb_in_curr: Max USB charger input current
246 * @ac_chg: AC charger power supply
247 * @usb_chg: USB charger power supply
248 * @ac: Structure that holds the AC charger properties
249 * @usb: Structure that holds the USB charger properties
256 * @check_usbchgnotok_work: Work for checking USB charger not ok status
257 * @kick_wd_work: Work for kicking the charger watchdog in case
259 * @ac_charger_attached_work: Work for checking if AC charger is still
261 * @usb_charger_attached_work: Work for checking if USB charger is still
263 * @ac_work: Work for checking AC charger connection
348 * should always be disabled when no charger is connected.
479 * ab8500_charger_get_ac_voltage() - get ac charger voltage
482 * Returns ac charger voltage in microvolt (on success)
488 /* Only measure voltage if the charger is connected */ in ab8500_charger_get_ac_voltage()
501 * ab8500_charger_ac_cv() - check if the main charger is in CV mode
504 * Returns ac charger CV mode (on success) else error code
511 /* Only check CV mode if the charger is online */ in ab8500_charger_ac_cv()
540 /* Only measure voltage if the charger is connected */ in ab8500_charger_get_vbus_voltage()
553 * ab8500_charger_get_usb_current() - get usb charger current
556 * This function returns the usb charger current.
563 /* Only measure current if the charger is online */ in ab8500_charger_get_usb_current()
576 * ab8500_charger_get_ac_current() - get ac charger current
579 * This function returns the ac charger current.
586 /* Only measure current if the charger is online */ in ab8500_charger_get_ac_current()
599 * ab8500_charger_usb_cv() - check if the usb charger is in CV mode
602 * Returns ac charger CV mode (on success) else error code
609 /* Only check CV mode if the charger is online */ in ab8500_charger_usb_cv()
634 * Returns the type of charger connected.
638 * interrupts of the charger detection
652 /* Check for AC charger */ in ab8500_charger_detect_chargers()
663 /* Check for USB charger */ in ab8500_charger_detect_chargers()
669 * charger was connected. Try waiting a little in ab8500_charger_detect_chargers()
735 * Dedicated charger level minus maximum current accessory in ab8500_charger_max_usb_curr()
744 * Dedicated charger level minus 120mA (20mA for ACA and in ab8500_charger_max_usb_curr()
768 dev_dbg(di->dev, "USB Type - Legacy charger.\n"); in ab8500_charger_max_usb_curr()
927 * This array maps the raw hex value to charger voltage used by the AB8500
1032 /* This array maps the raw register value to charger input current */
1038 /* This array maps the raw register value to charger output current */
1124 * @reg: select what charger register to check
1127 * Checks if charger source has not collapsed. If it has, further stepping
1140 * ab8500_charger_set_current() - set charger current
1142 * @ich_ua: charger current, in uA
1143 * @reg: select what charger register to set
1145 * Set charger current.
1146 * There is no state machine in the AB to step up/down the charger
1149 * this charger current step-up/down here.
1220 dev_dbg(di->dev, "%s set charger current: %d uA for reg: 0x%02x\n", in ab8500_charger_set_current()
1268 * @ich_in_ua: charger input current limit in microampere
1311 * ab8500_charger_set_main_in_curr() - set main charger input current
1313 * @ich_in_ua: input charger current, in uA
1315 * Set main charger input current.
1326 * ab8500_charger_set_output_curr() - set charger output current
1328 * @ich_out_ua: output charger current, in uA
1330 * Set charger output current.
1393 static int ab8500_charger_ac_en(struct ux500_charger *charger, in ab8500_charger_ac_en() argument
1402 struct ab8500_charger *di = to_ab8500_charger_ac_device_info(charger); in ab8500_charger_ac_en()
1407 dev_err(di->dev, "AC charger not connected\n"); in ab8500_charger_ac_en()
1419 * there is a charger enabled. Normally the VDD ADC supply in ab8500_charger_ac_en()
1440 "Charger voltage or current too high, " in ab8500_charger_ac_en()
1452 /* MainChInputCurr: current that can be drawn from the charger*/ in ab8500_charger_ac_en()
1473 /* Enable Main Charger */ in ab8500_charger_ac_en()
1493 * kick the charger watchdog even when no charger is in ab8500_charger_ac_en()
1494 * connected. This is only valid once the AC charger in ab8500_charger_ac_en()
1497 * by the charger driver when the AC charger in ab8500_charger_ac_en()
1565 * @ich_out_ua: charger output current in microampere
1570 static int ab8500_charger_usb_en(struct ux500_charger *charger, in ab8500_charger_usb_en() argument
1578 struct ab8500_charger *di = to_ab8500_charger_usb_device_info(charger); in ab8500_charger_usb_en()
1583 dev_err(di->dev, "USB charger not connected\n"); in ab8500_charger_usb_en()
1592 * there is a charger enabled. Normally the VDD ADC supply in ab8500_charger_usb_en()
1614 "Charger voltage or current too high, " in ab8500_charger_usb_en()
1633 /* Enable USB Charger */ in ab8500_charger_usb_en()
1721 * @charger: pointer to the ux500_charger structure
1723 * @iset_ua: charger output current in microampere
1725 * Check if the VBUS charger has been disconnected and reconnected without
1728 static int ab8500_charger_usb_check_enable(struct ux500_charger *charger, in ab8500_charger_usb_check_enable() argument
1734 struct ab8500_charger *di = to_ab8500_charger_usb_device_info(charger); in ab8500_charger_usb_check_enable()
1745 dev_dbg(di->dev, "USB charger ctrl: 0x%02x\n", usbch_ctrl1); in ab8500_charger_usb_check_enable()
1760 dev_err(di->dev, "Failed to enable VBUS charger %d\n", in ab8500_charger_usb_check_enable()
1770 * @charger: pointer to the ux500_charger structure
1772 * @iset_ua: charger output current in micrompere
1774 * Check if the AC charger has been disconnected and reconnected without
1777 static int ab8500_charger_ac_check_enable(struct ux500_charger *charger, in ab8500_charger_ac_check_enable() argument
1783 struct ab8500_charger *di = to_ab8500_charger_ac_device_info(charger); in ab8500_charger_ac_check_enable()
1794 dev_dbg(di->dev, "AC charger ctrl: 0x%02x\n", mainch_ctrl1); in ab8500_charger_ac_check_enable()
1810 dev_err(di->dev, "failed to enable AC charger %d\n", in ab8500_charger_ac_check_enable()
1819 * ab8500_charger_watchdog_kick() - kick charger watchdog
1822 * Kick charger watchdog
1825 static int ab8500_charger_watchdog_kick(struct ux500_charger *charger) in ab8500_charger_watchdog_kick() argument
1830 if (charger->psy->desc->type == POWER_SUPPLY_TYPE_MAINS) in ab8500_charger_watchdog_kick()
1831 di = to_ab8500_charger_ac_device_info(charger); in ab8500_charger_watchdog_kick()
1832 else if (charger->psy->desc->type == POWER_SUPPLY_TYPE_USB) in ab8500_charger_watchdog_kick()
1833 di = to_ab8500_charger_usb_device_info(charger); in ab8500_charger_watchdog_kick()
1846 * ab8500_charger_update_charger_current() - update charger current
1847 * @charger: pointer to the ab8500_charger structure
1850 * Update the charger output current for the specified charger
1853 static int ab8500_charger_update_charger_current(struct ux500_charger *charger, in ab8500_charger_update_charger_current() argument
1859 if (charger->psy->desc->type == POWER_SUPPLY_TYPE_MAINS) in ab8500_charger_update_charger_current()
1860 di = to_ab8500_charger_ac_device_info(charger); in ab8500_charger_update_charger_current()
1861 else if (charger->psy->desc->type == POWER_SUPPLY_TYPE_USB) in ab8500_charger_update_charger_current()
1862 di = to_ab8500_charger_usb_device_info(charger); in ab8500_charger_update_charger_current()
1942 * charger when charging with at some specific levels. This issue is only valid
1986 * ab8500_charger_check_hw_failure_work() - check main charger failure
1989 * Work queue function for checking the main charger status
2036 * Work queue function for kicking the charger watchdog.
2039 * logic. That means we have to continuously kick the charger
2040 * watchdog even when no charger is connected. This is only
2041 * valid once the AC charger has been enabled. This is
2043 * watchdog have to be kicked by the charger driver
2044 * when the AC charger is disabled
2064 * ab8500_charger_ac_work() - work to get and set main charger status
2067 * Work queue function for checking the main charger status
2078 * synchronously, we have the check if the main charger is in ab8500_charger_ac_work()
2311 "Invalid charger detected, state= 0\n"); in ab8500_charger_usb_link_status_work()
2312 /*Enable charger*/ in ab8500_charger_usb_link_status_work()
2316 /*Enable charger detection*/ in ab8500_charger_usb_link_status_work()
2327 "Invalid charger detected, state= 1\n"); in ab8500_charger_usb_link_status_work()
2328 /*Stop charger detection*/ in ab8500_charger_usb_link_status_work()
2362 /* No valid charger type detected */ in ab8500_charger_usb_link_status_work()
2371 "Potential Legacy Charger device. " in ab8500_charger_usb_link_status_work()
2459 * Work queue function for checking the USB charger Not OK status
2554 * ab8500_charger_mainchunplugdet_handler() - main charger unplugged
2564 dev_dbg(di->dev, "Main charger unplugged\n"); in ab8500_charger_mainchunplugdet_handler()
2575 * ab8500_charger_mainchplugdet_handler() - main charger plugged
2585 dev_dbg(di->dev, "Main charger plugged\n"); in ab8500_charger_mainchplugdet_handler()
2599 * ab8500_charger_mainextchnotok_handler() - main charger not ok
2609 dev_dbg(di->dev, "Main charger not ok\n"); in ab8500_charger_mainextchnotok_handler()
2620 * ab8500_charger_mainchthprotr_handler() - Die temp is above main charger
2632 "Die temp above Main charger thermal protection threshold\n"); in ab8500_charger_mainchthprotr_handler()
2639 * ab8500_charger_mainchthprotf_handler() - Die temp is below main charger
2651 "Die temp ok for Main charger thermal protection threshold\n"); in ab8500_charger_mainchthprotf_handler()
2759 * ab8500_charger_usbchthprotr_handler() - Die temp is above usb charger
2771 "Die temp above USB charger thermal protection threshold\n"); in ab8500_charger_usbchthprotr_handler()
2778 * ab8500_charger_usbchthprotf_handler() - Die temp is below usb charger
2790 "Die temp ok for USB charger thermal protection threshold\n"); in ab8500_charger_usbchthprotf_handler()
2797 * ab8500_charger_usbchargernotokr_handler() - USB charger not ok detected
2807 dev_dbg(di->dev, "Not allowed USB charger detected\n"); in ab8500_charger_usbchargernotokr_handler()
2814 * ab8500_charger_chwdexp_handler() - Charger watchdog expired
2824 dev_dbg(di->dev, "Charger watchdog expired\n"); in ab8500_charger_chwdexp_handler()
2827 * The charger that was online when the watchdog expired in ab8500_charger_chwdexp_handler()
2853 dev_dbg(di->dev, "VBUS charger drop ended\n"); in ab8500_charger_vbuschdropend_handler()
2937 * for the AC charger in ab8500_charger_ac_get_property()
3005 * for the USB charger in ab8500_charger_usb_get_property()
3019 * due to too high output current from the USB charger in ab8500_charger_usb_get_property()
3033 * ab8500_charger_init_hw_registers() - Set up charger related registers
3036 * Set up charger OVV, watchdog and maximum voltage registers as well as
3043 /* Setup maximum charger current and voltage for ABB cut2.0 */ in ab8500_charger_init_hw_registers()
3132 dev_err(di->dev, "failed to set charger watchdog timeout\n"); in ab8500_charger_init_hw_registers()
3165 * ab8500 charger driver interrupts and their respective isr
3202 /* TODO: State is fabricate here. See if charger really needs USB in ab8500_charger_usb_notifier_call()
3241 * logic. That means we have to continuously kick the charger in ab8500_charger_resume()
3242 * watchdog even when no charger is connected. This is only in ab8500_charger_resume()
3243 * valid once the AC charger has been enabled. This is in ab8500_charger_resume()
3245 * watchdog have to be kicked by the charger driver in ab8500_charger_resume()
3246 * when the AC charger is disabled in ab8500_charger_resume()
3324 /* Create a work queue for the charger */ in ab8500_charger_bind()
3424 "failed to get ADC main charger voltage\n"); in ab8500_charger_probe()
3430 "failed to get ADC main charger current\n"); in ab8500_charger_probe()
3437 "failed to get ADC USB charger voltage\n"); in ab8500_charger_probe()
3443 "failed to get ADC USB charger current\n"); in ab8500_charger_probe()
3449 * is a charger connected to avoid erroneous BTEMP_HIGH/LOW in ab8500_charger_probe()
3509 * AB8505, register an AC charger. in ab8500_charger_probe()
3544 * logic. That means we have to continuously kick the charger in ab8500_charger_probe()
3545 * watchdog even when no charger is connected. This is only in ab8500_charger_probe()
3546 * valid once the AC charger has been enabled. This is in ab8500_charger_probe()
3548 * watchdog have to be kicked by the charger driver in ab8500_charger_probe()
3549 * when the AC charger is disabled in ab8500_charger_probe()
3566 /* Init work for charger detection */ in ab8500_charger_probe()
3587 /* Register AC charger class */ in ab8500_charger_probe()
3593 dev_err(dev, "failed to register AC charger\n"); in ab8500_charger_probe()
3598 /* Register USB charger class */ in ab8500_charger_probe()
3603 dev_err(dev, "failed to register USB charger\n"); in ab8500_charger_probe()
3616 /* Identify the connected charger types during startup */ in ab8500_charger_probe()
3698 { .compatible = "stericsson,ab8500-charger", },
3707 .name = "ab8500-charger",
3744 MODULE_ALIAS("platform:ab8500-charger");
3745 MODULE_DESCRIPTION("AB8500 charger management driver");