summaryrefslogtreecommitdiff
path: root/drivers/power
AgeCommit message (Collapse)Author
2016-10-25Merge "qpnp-fg-gen3: Fix storing nominal capacity to actual capacity"Linux Build Service Account
2016-10-24qpnp-fg-gen3: Fix storing nominal capacity to actual capacitySubbaraman Narayanamurthy
Currently, nominal capacity is stored back to the actual capacity only when the actual capacity is non-zero. However, that can be true when the battery is inserted for the first time. This makes the actual capacity to be stored only when a capacity learning cycle completes. Other algorithms like to use actual capacity before that. Fix it. Change-Id: I346085ec722f491f96181ef1beb383710b441f4b Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
2016-10-24smb-lib: update displaying battery overvoltage in health propertySubbaraman Narayanamurthy
Currently, smb2 charger is configured to not end the charging cycle when battery overvoltage occurs. However, when the battery overvoltage status is read, it will be displayed through health property. Improve this by reading the battery voltage and check whether it is within 40mV headroom above float voltage. If it is above that threshold then continue with displaying overvoltage status. CRs-Fixed: 1079363 Change-Id: I45847f446c91c80a5110d80b59a0ae4b8e2c40e5 Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
2016-10-22Merge "smb1351-charger: Fix possible Null pointer dereference"Linux Build Service Account
2016-10-22Merge "qpnp-fg-gen3: Backup the learned capacity during capacity learning"Linux Build Service Account
2016-10-22Merge "qpnp-fg-gen3: update the FCC unit while notifying charger"Linux Build Service Account
2016-10-21qpnp-fg-gen3: fix the error in showing battery temperatureSubbaraman Narayanamurthy
Battery temperature can take negative values. FG driver reads it as an unsigned value and hence the negative reading is treated as a huge integer value. Fix it. CRs-Fixed: 1081146 Change-Id: I63e8863efb91af891dbcbfc070dfdcd833ea3ad4 Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
2016-10-20Merge "fg-util: fix a possible buffer overflow"Linux Build Service Account
2016-10-20smb1351-charger: Fix possible Null pointer dereferenceAbhijeet Dharmapurikar
The adc notification callback assumes that it will end up selecting the correct state. However, if the parameters are outside the expected values, the code could end up dereferencing a null pointer. Fix this by returning before that pointer is dereferenced. Change-Id: I42642b475a1032c3a7395336381f3bd6c1396dde Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-20qpnp-fg-gen3: update the FCC unit while notifying chargerSubbaraman Narayanamurthy
Charger driver expects the constant_charge_current_max property in microunits. Update it. Change-Id: I1b9117edb6c2206c09deb083529479a3ccc4618d Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
2016-10-20Merge "qpnp-fg-gen3: notify charger with float voltage and FCC"Linux Build Service Account
2016-10-20Merge "qpnp-smb2: support setting FCC and float voltage in battery power supply"Linux Build Service Account
2016-10-19Merge "power_supply: Add PE_START property"Linux Build Service Account
2016-10-19Merge "qpnp-smb2: Fix LIMITED reporting"Linux Build Service Account
2016-10-19Merge "qcom-charger: smblib: change secure address threshold"Linux Build Service Account
2016-10-19qpnp-fg-gen3: notify charger with float voltage and FCCSubbaraman Narayanamurthy
Whenever the battery profile is loaded, notify charger SW with float voltage and FCC obtained from the battery profile. Change-Id: I0419b34fde9d74460b849ee8a7ef7e2cdf5592d2 Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
2016-10-19qpnp-smb2: support setting FCC and float voltage in battery power supplyHarry Yang
Fast charge current (FCC) and float voltage are parameters that are battery specific and needs to be set based on the profile detected by Fuel Gauge driver. Expose the following properties from battery power supply so that FG can set them. - POWER_SUPPLY_PROP_VOLTAGE_MAX - POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX Change-Id: I72465484b154b1a758285d58906ce7661a246767 Signed-off-by: Harry Yang <harryy@codeaurora.org> Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
2016-10-19qcom-charger: smb2: disable EN_TRY_SINK_MODE for PDHarry Yang
Try.SNK is not permitted in PD per spec. Disable it while pd_active is true. Change-Id: I90891232d37b95f011b3f2d5278f0fd0f4c9eb71 Signed-off-by: Harry Yang <harryy@codeaurora.org> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-19qpnp-smb2: implement PE_START propertyAbhijeet Dharmapurikar
The policy engine needs to be informed that its time to start its activities when APSD results are available and/or PD_ALLOWED is decided. USB type property shouldn't change after that. Since HVDCP_TIMEOUT_VOTER is the last one to cast its allow vote in the sequence, use it to reflect the PE_START property. While at it since PE_START property is returned assuming an atomic context, the read of PD_ALLOWED could be moved to its sleepable variants. This aids in keeping the policy engine code simple and also assures race free code. Change-Id: Ib98ac10d87200a2fd5492e27399f696f2468eba6 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-19power_supply: Add PE_START propertyAbhijeet Dharmapurikar
This property will be used to indicate to the policy engine that it should start its activities. Change-Id: I9deb48f7bff71b022c5899e6eff7617526d02324 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-19qpnp-smb2: Fix LIMITED reportingAbhijeet Dharmapurikar
A merge conflict resolution caused a break statement to be dropped in the case block for reporting input_current_limited property. Fix this. Change-Id: Ic5c9626628f05f3167f9f8d0b78b04b83446f413 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-19qcom-charger: smblib: change secure address thresholdHarry Yang
Correct the secure address threshold to 0x0A since Misc peripheral has secure registers starting as early as 0x0A CRs-Fixed: 1048242 Change-Id: Id7ec03919e2fd08540cd7e677bf5e4048d73c23d Signed-off-by: Harry Yang <harryy@codeaurora.org>
2016-10-19qpnp-smb2: expose parallel slave percentage via battery psyNicholas Troast
Expose the parallel distribution percentage and allow it to be modified. Change-Id: I0c9221c6a748aff5e8fbe889316f729155eded3e Signed-off-by: Nicholas Troast <ntroast@codeaurora.org> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-19smb-lib: qpnp-smb2: fix input collapse by limiting slave FCCNicholas Troast
The parallel charger can collapse the input adapter. Impose a power limit on the slave charger by limiting the slave FCC. Change-Id: I02a3dc02911646240a1ecee41584903aab971d81 Signed-off-by: Nicholas Troast <ntroast@codeaurora.org> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-19Merge "qpnp-smb2: handle DC insertion"Linux Build Service Account
2016-10-19Merge "smb-lib: qpnp-smb2: cleanup parallel charging code"Linux Build Service Account
2016-10-19Merge "driver: bcl_peripheral: Input correct dmac flush range argument"Linux Build Service Account
2016-10-18qpnp-fg-gen3: Backup the learned capacity during capacity learningSubbaraman Narayanamurthy
When the capacity learning algorithm completes, we store the learned capacity to BattCapActual word in FG SRAM. Though this is correct and needed for coulomb counter to operate, value is not retained across reboot. Backup the learned capacity to a scratchpad SRAM word (address 74) to overcome this. Change-Id: I39c257876776a9e9c872add1366569394c49ef01 Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
2016-10-19qpnp-smb2: handle DC insertionAbhijeet Dharmapurikar
Update the power_supply framework of a dc insertion/removal. Change-Id: I786d0774589ae64b298754286be28d67d394a66d Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-18driver: bcl_peripheral: Input correct dmac flush range argumentRam Chandrasekar
Correct the input argument to pass in the valid end address for the dmac flush range function. Change-Id: If6db015558a6a9e3db53ba7f1455808e779da908 Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2016-10-17fg-util: fix a possible buffer overflowSubbaraman Narayanamurthy
If the string passed is of a huge size, then bytes_read can be higher and can overflow "pos" to a small value. This can cause a potential buffer overflow when "pos" is used again in sscanf. Fix this by validating bytes_read before it is used. CRs-Fixed: 1077693 Change-Id: I59d4472b49b67f481992867a34e6779a4589d035 Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
2016-10-17smb-lib: qpnp-smb2: cleanup parallel charging codeAbhijeet Dharmapurikar
The parallel charging code has grown organically. Clean up the following: 1. Use correct units for all unit based variables. 2. Use slave percent instead of master percent. 3. Remove parallel master module parameter. 4. Put PARALLEL_DISABLE where it belongs in battery psy. 5. Create a get_jeita_cc_delta function similar to get_step_cc_delta function. 6. Print errors when returning error codes. Change-Id: I27ec29c3a6c5f3aac31705e60e1b8cf3270322a1 Signed-off-by: Nicholas Troast <ntroast@codeaurora.org> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17smb138x-charger: supporting switching freq propHarry Yang
Allow for changing the switching frequency via a power supply property. The main charger will call this property to ensure optimal power dissipation. CRs-Fixed: 1048242 Change-Id: I17aeabe9c20388747dc1965bef22127bd054a828 Signed-off-by: Harry Yang <harryy@codeaurora.org> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17power_supply: add property to reflect switcher frequencyHarry Yang
Modern battery chargers use a switching buck whose frequency can be adjusted. Create a property to read/update it. CRs-Fixed: 1048242 Change-Id: I7611e6b697222427303df47f837716005e013443 Signed-off-by: Harry Yang <harryy@codeaurora.org> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17smb-lib: fix type not updating to Unknown after removalAbhijeet Dharmapurikar
There is a possibility where the driver fails to change the usb type to Unknown when the cable is removed - in particular when pd is not allowed. Use the debounce done event of the typec change interrupt to update the usb type to Unknown. Change-Id: I7f201209101e54461e3d08d677bd7b266f971420 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17qpnp-smb2: print function names in debug statementsAbhijeet Dharmapurikar
Currently the driver uses the dev_ variants to print debug information. This is not useful. Instead print the function name and use pr_ variants to print debug information. Change-Id: I0eeb61e847b07ac9b7622ac521bace24a417bb14 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17smb-lib: rerun apsd if not pdAbhijeet Dharmapurikar
If an HVDCP charger is detected and it does not support PD, that means it is likely a legacy QC2 or QC3 charger. Rerun APSD when PD sets us to be inactive. For cases when pd is not allowed, PD won't set inactive status. For such cases use the hvdcp_timeout interrupt to rerun APSD. Change-Id: Ibe03e1dc88700b605e2f43ee4bca266ce3dee92b Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17smb-lib: support separate current settings from usb and pdAbhijeet Dharmapurikar
Add support to set current limits from usb and pd. Ensure that the limit from the pd is only enforced when pd is active and that the limit from usb is enforced only when pd is inactive. There is one situation when the input needs to be suspended as per the usb driver's request when pd sets system_suspend_supported. For that allow the usb voter to set that low current value to suspend. Also ensure that the pd and usb votes are nullified when source is removed. In addition, the return the individual valid votes from usb and pd when their current_max are read. Change-Id: I215e9e82f44061c4083a4df8cab400beadf6322d Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17smb-lib: provide insertion removal functionsAbhijeet Dharmapurikar
The current driver votes and unvotes for removal/insertion at two interrupt handlers, debounce done and the type C detach. The recommendation from hw teams is to use debounce done for both insertion and removal. Update the code. While at it, provide clean functions to vote and unvote for four situations a typec cable insertion a typec cable removal a source insertion a source removal Note that this allows us to cleanly handle PD hard resets where the typec connection remains intact but the source (or vbus) related state needs to be reset. This also helps us in cleanly handling power sole swaps where the source plugged and removed functions handle vbus related states while typec functions handle the typec related states. Change-Id: I49fccb1fcf8eaea8fea1ae186906689a628c02f8 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17qpnp-smb2: handle shorted vbus and cc lines and legacy cablesAbhijeet Dharmapurikar
There could be cables where vbus and cc lines are shorted or connected using a small resistor. Raising VBUS to higher values could cause CC line to get damaged. CC line cannot tolerate a voltage higher than 6V. So if such a cable is seen, prevent pd stack from running so there is no opportunity to increase vbus by selecting a higher voltage profile. Also disable HVDP too. Also, prevent PD_ALLOWED if a legacy cable is seen - the spec mentions that if VBUS is seen along with CC, the adapter is not pd capable. Change-Id: I7411bd541ffe704dda97dd869a3dbd4dbfc99518 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17qpnp-smb2: update to USB_PD type when pd is activeAbhijeet Dharmapurikar
Since the USB_PD type is no more set by the PD driver, it is expected that the type be set based on pd_active property being ACTIVE. So set the type and update the userspace when it changes. Change-Id: I0f76f092d3e8de7a916e995e4d825fe0da79bf78 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17qpnp-smb2: support exiting sink based on ccAbhijeet Dharmapurikar
While PD is under hard reset and the device is in sink mode, it shouldn't leave sink mode because VBUS goes away. Instead it should stay in sink mode while hard reset is being conducted and exit sink mode only if CC gets detached. Configure the exit state when hard reset is in progress. Also while hard reset is in progress disable APSD else a APSD could run and disturb SDP communication after VBUS recovers in hard reset procedure. Change-Id: I7f5046d4822438e949658356e683e74acfa664f7 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17qcom-charger: Allow PD for hvdcpAbhijeet Dharmapurikar
Currently the code prevents pd if an hvdcp is detected. We want to change that in that we want to prevent pd only while hvdcp detection is in progress. Once completed, we need to enable pd even if an hvdcp is detected. Enabling PD even for hvdcp allows us to detect a QC 4.0 which communicates over PD. Currently we model the pd_allowed votable as an enable votable i.e. if any one of the voters enable it, pd_allowed gets enabled. Change that to a disable votable named pd_disallowed_votable, which gets disabled when CC is detached, and hvdcp2.0 detection is not yet completed. Change-Id: I2ae261c71694695b41d8a31c4b40542d5e227c3a Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17qpnp-smb2: Disable hvdcp based on user configurationAbhijeet Dharmapurikar
Some platforms do not support HVDCP charging. Provide means to disable them. Provide a votable for disabling HVDCP in preparation to handle VBUS and CC line shorted situation. Note that when hvdcp is disabled, we only disable voltage negotiations i.e. qc 2.0 detection remains enabled since it does not need voltage to change. Change-Id: Id7eaa46f08ac451a918a550f7837efbef78ab6f6 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-17qcom-charger: qpnp-smb2: configure float options from DTNicholas Troast
When a float charger is detected by APSD there are configuration options that change the behavior of the charger. These options should be configurable from the device tree. Add a DT parameter "qcom,float-option" and configure it as follows: 1 - Treat as a DCP 2 - Treat as a SDP 3 - Disable charging 4 - Suspend USB input Change-Id: Ia9219bc232f2092569dfb1a14f628e788173c4ff Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
2016-10-17qpnp-smb2: add debugfs entries to force power supply updatesNicholas Troast
It is useful when debugging to force power supply changed events. Add debugfs entries for each power supply to allow forcing power supply changed events. Change-Id: I018eb018de2a8119acc09824c82cca8ff1b52faa Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
2016-10-17power_supply: add PARALLEL_PERCENT propertyNicholas Troast
The PARALLEL_PERCENT property is used for the parallel distribution percentage. Change-Id: I7d2a7a775437770075ddbd2d1a36ce5d9e44a631 Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
2016-10-17smb-lib: set ICL to 900mA when USB 3.0 has enumeratedNicholas Troast
900mA can be drawn from a USB 3.0 port that has been enumerated. Do it. Change-Id: I94e5d36feb3cd54bcc46e8c56933340cad839c1f Signed-off-by: Nicholas Troast <ntroast@codeaurora.org> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2016-10-14power_supply: Add additional USB PD propertiesJack Pham
Add additional properties for USB PD usage: - POWER_SUPPLY_PROP_PD_IN_HARD_RESET is set when PD is undergoing a hard reset - POWER_SUPPLY_PROP_PD_CURRENT_MAX used to indicate the current limit as negotiated over PD - POWER_SUPPLY_PROP_PD_USB_SUSPEND_SUPPORTED is set when USB suspend current limit must be honored when USB bus is suspended Also add enums to distinguish PD activity state: inactive, active. Change-Id: I0a3d98ac1e1202e5b655b2e3a8102691b61359c8 Signed-off-by: Jack Pham <jackp@codeaurora.org>
2016-10-13Merge "qpnp-fg-gen3: add support to configure ki coefficients during discharge"Linux Build Service Account