Solution for USB charger in Linux Kernel

Source: Internet
Author: User

The latest kernel (v3.5) currently does not support the overall USB charger solution. The USB charger solution discussed here only refers to the software solution, that is, the charger detection needs to be performed by software intervention (such as reading the usb phy register), and the battery charging value needs to be set by the software according to different charger types. This topic is not discussed here. The advantages of the software solution are: eliminating the need for a USB charger detection chip and using a simpler (cheaper) battery management chip. The disadvantage of www.2cto.com is that software intervention (possibly with bugs) and cannot achieve high charging current in the case of low power. A complete set of USB charger solutions should include: 1. USB Charger identification, it is determined that the USB Charger is one of the following USB Charger:-SDP (Standard Downstream Port)-DCP (Dedicated Charging Port)-CDP (Charging Downstream Port) -ACA (Accessory Charger Adapters) generally recognizes SDP and DCP (dedicated charger, DP, and DM transient connections ). 2. USB charger identification and battery management chip interface is how to inform the battery management chip of the charging result, the kernel Power Supply framework is used here. In the software-based USB charging scheme, there are usually two drivers, because the charger Identification Module and the battery charging module are two hardware modules. Based on my understanding of the corresponding kernel code, there are two ways to implement the Linux USB charger solution. Www.2cto.com Method 1: 1. 1.1 set a notifier in the identification drive of the USB charger (in the usb phy or in a separate charger drive). After the charger is identified, pass the corresponding event and value to the user registered on the notifier. Call the probe function:
Callback (& notifier); Call: atomic_notifier_call_chain (& notifier, event, v) after detection is complete; 1.2 also implement: psy-> external_power_changed (psy is the pointer of struct power_supply ), in this way, after the charger is identified, call [1] power_supply_changed (psy) to change the corresponding property value. Then, the user program can know all the property values through/sys/class/power_supply. 2. 2.1 register a notifier in the battery drive and the corresponding notifier function probe function: usb_phy = usb_get_transceiver (); usb_register_notifier (usb_phy, nb); nb. notifier_call = set_charging_current; 2.2 set_charger_current function: set the value of the charging current to the battery management chip, which is usually completed using I2C or SPI interfaces. (Depending on the serial interface of the battery management chip ). Www.2cto.com solution 2: notifier interfaces are not required in two drivers. 1. To achieve this in the battery management chip drive, Part 1 of solution 1. 2. In the battery management chip drive, use power_supply_get_by_name (name) to obtain the pointer corresponding to power supply. The name here can be input by platform data or written in the corresponding node of the device tree. This name must be the same as the name of the recognized driver registered for the USB charger. [1] to implement this function, you also need the following patch: Subject: [PATCH] power_supply: add get_supplier_property Signed-off-: heikki Krogerus

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.