Currently, when "qcom,thermal-levels" is specified and the
values are not in descending order, an error is returned which
fails the driver probe thereby causing battery/USB power supply
not available. Same problem can happen when charger firmware
returns a lower value for BATT_CHG_CTRL_LIM_MAX than the maximum
value specified under "qcom,thermal-levels" property. Without a
battery power supply, user would not know the battery charging
status. To avoid this, just return 0 after printing an error.
This would only affect the user by disallowing a change to the
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT property under battery
power supply.
Change-Id: I216d4d370e71ec5003adbee2600191e36a45e870
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Setting a fake battery SOC (state of charge) is useful to test
different mitigation levels. Add support for it by exposing
fake_soc under qcom-battery class which can be set only when
CONFIG_QTI_PMIC_GLINK_CLIENT_DEBUG is enabled.
To set fake_soc of 50%,
echo 50 > /sys/class/qcom-battery/fake_soc
To clear fake_soc so that actual battery SOC can be displayed,
any value other than 0-100 can be set to fake_soc.
echo -1 > /sys/class/qcom-battery/fake_soc
Change-Id: Ibff337fb4da9d4e9aadbe148f3eecca9e2d69604
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Add subsystem restart (SSR) support to battery charger driver so
that it can stop read/write properties when subsystem goes down.
Also, send message to enable notification again once subsystem
comes up.
Change-Id: I64f3abfa1d12c4e6a65fd01d7f66155c8741e68a
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Input Current Limit (ICL) needs to be set only for SDP and not
for other charger types. Add that logic.
Change-Id: Ib48acf5666ea4190b7a11c27ab9cefbb534632fb
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Fix pmic_glink_client_data initialization without which ssr_cb
that would be added in the upcoming patch causes an incorrect
list addition to PMIC Glink notification list.
Change-Id: I7588ae894e8188c30456f4c16711bc6b757a9863
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Add "qcom,thermal-mitigation" property to specify charging
current thresholds for thermal mitigation levels. These values
will be passed on to the charger firmware running on a remote
subsystem when thermal SW sets CHARGE_CONTROL_LIMIT property in
battery power supply.
Change-Id: I67be3f9012718de9b2cd529ed6043fb54f503003
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Charger firmware sends some battery related events with a generic
notification opcode. Handle such notifications as well to send
events up to the userspace.
Change-Id: Ia35fb7dbe56183d3c7c7a66b5f387b94072e6ed0
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Add Qualcomm Technologies, Inc. battery charger driver which
interfaces with the charger firmware running on the remote
subsystem (e.g. DSP) by communicating over PMIC Glink channel and
provides information about the battery, USB and wireless charging
by exposing them as power supply devices.
Change-Id: I36a2efd0b66bc5f79515b5faa318c537a5927e76
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Add a check to ensure that the remote subsystem sends the full and
expected length of the notification message.
Change-Id: I78d2c708c924cb864b7636bda81f290e310beb54
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Execute the client's callback in a separate thread to avoid the
following deadlock situation:
- altmode_callback() calls the client's callback when a valid amclient
is found and program execution waits for it to finish.
- The client's callback calls altmode_send_data() to send the PAN_ACK.
- altmode_send_data() eventually calls altmode_write(), which is waiting
for the response_received to be "completed" in altmode_callback().
- For response_received to be "completed", altmode_callback() must
finish executing in order to process the USBC_CMD_WRITE_REQ message
received from the remote subsystem.
- altmode_callback() cannot finish executing until altmode_send_data()
returns.
- altmode_send_data() times out and passes on the error to the client.
Also perform the following:
- Add a check to ensure that the payload received from the remote
subsystem is at least 9 bytes long.
- Prevent out of bounds access for USBC_CMD_WRITE_REQ message (which is
of a different format than struct usbc_notify_ind_msg) by moving the
port_index reading to only the USBC_NOTIFY_IND message in
altmode_callback().
CRs-Fixed: 2713590
Fixes: 6c0ffc67e574 ("soc: altmode: Detect when remote subsys fails to respond")
Change-Id: I0f2c6ce0f843c43c9e7e301be9ff3ad913310f62
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
The remote subsystem acknowledges all Altmode PMIC GLINK messages sent
to it. Print an error message anytime it fails to do this.
In the case when no client is found for a received message, do the
sending of the ack in a separate worker thread instead of a plain
function call to altmode_send_ack(). This is to avoid a deadlock and
consequent timing out in altmode_write(), which will happen in the
following scenario:
- A message is received for a nonexistent client.
- altmode_send_ack() is called from within altmode_callback().
- The PAN ACK is sent to the remote subsystem via pmic_glink_write() in
altmode_write() and the remote subsystem replies with an ACK (opcode
USBC_CMD_WRITE_REQ).
- Subsequently, in altmode_write() we wait for completion timeout, which
will happen only if this new ACK message is processed by PMIC GLINK.
- PMIC GLINK is waiting for altmode_callback() to return so that it can
process the new message.
- We are still waiting in altmode_callback() for altmode_send_ack() to
complete.
- We time out in altmode_write() waiting for the completion to occur.
This problem is solved by firing off a worker thread to send the PAN ACK
so that altmode_callback() can exit quickly and allow the incoming new
ACK to hit the complete() in the USBC_CMD_WRITE_REQ case in
altmode_callback().
Also add a couple of minor fixes to some debug messages while we're at
it.
Change-Id: I3d80b1a7d6cc03b0eba61b5c9cc660ce7d377942
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Add debugfs nodes to send Pin Assignment Notifications Enable (PAN EN)
and Acknowledgment (ACK) commands manually if needed, to aid in
debugging situations where it is unclear whether clients are sending
these commands synchronously as per design.
Change-Id: I7a68d676df86cbf6952158202c8e4958db032d5b
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Remove the device tree property "qcom,altmode-name" and the logic it
feeds as it was meant to help in the cases when there are multiple
altmode devices. Since there is going to be only one altmode device as
per design, this is no longer needed.
Change-Id: Ife15e39becee5f4ff03bdcc56ff62ae812fe2726
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Client API changes:
- Update client APIs to align them more closely with upstream
conventions.
- In particular, change the link between altmode device and client from
the altmode device's name string to a phandle to the altmode device
followed by the port index of the client.
- Instead of using solely the client's SVID as the key for idr_alloc,
include port_index as well because the unique identifier of a client
is the (SVID, port_index) tuple.
Updates to client notifying mechanism:
- Get rid of the standard notifier APIs in favour of a simpler callback
function-based mechanism to notify clients of probe completion.
- In addition, if clients probe after altmode finishes probing, they
will not get notified of probe completion as this is done only once at
the end of altmode_probe(). Fix this so that if a client registers for
probe completion notifications after altmode probes, they get notified
immediately.
While at it, get rid of the global list of altmode devices (amdev_list)
as there will only be a single altmode device in the system as per
design.
Change-Id: Iea450d30d9cc94671f505b7ff0c6e98b0b8a4467
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Add subsystem restart (SSR) support to altmode glink driver so
that when subsystem goes down and comes up again, it can send
PAN_EN to charger firmware to receive notifications about altmode
interface.
Change-Id: Ie011d5110b6c26790fe1dd6149115019f8bc261c
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
The Type-C standard defines various "alternate (alt) modes" which enable
standard Type-C connectors to carry non-USB signals and data.
This driver provides an interface for Type-C alternate mode clients to
receive data such as Pin Assignment Notifications from the Type-C stack
running on a remote subsystem (e.g. DSP) via the PMIC GLINK interface.
Change-Id: Ic7eacb6901830cab181d91a1775cf02cddbccae2
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Currently, qti_battery_debug driver supports collecting QBG
context dump only for 1S battery. Add support to collect QBG
context dump for more than single cell to support 2S battery.
User can set "battery_cell_id" to select the QBG context dump
they would like to receive from the charger firmware that runs
on a remote subsystem.
Change-Id: I863b908a8c5bfae441431d31ac4dc8a491a0310c
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Replace the "qbg_context" debugfs blob with a binary file associated
with the battery_debug device that provides the same functionality as
the existing debugfs blob for getting QBG context.
Usage:
# cd /sys/devices/platform/soc/soc:qcom,pmic_glink_log/\
soc:qcom,pmic_glink_log:qcom,battery_debug
# echo 1 > qbg_context
# cat qbg_context > file.bin
Change-Id: I59cfea2880362a95d8c87c02b4d823bfdca4e1e2
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Ensure that valid memory is allocated for the array of all votables
before an attempt is made to populate it.
Change-Id: I9a0c3e35e345a88560e39d47484348b6c476628d
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
As a preparatory move to adding device attributes to the battery_debug
device, remove the dependency on DEBUG_FS for driver enablement and add
config guards in the driver instead.
Change-Id: I8fcb385a583564935ce472416552e25ca79f4a84
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Add debugfs nodes to read and set votables from the firmware running on
the remote subsystem (e.g. DSP).
Also modify error handling logic in battery_dbg_add_debugfs().
Change-Id: I50f191add22cd500e04475f264e86cf16c6be48f
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
QBG device context dump length has been increased to 598 words in
the charger firmware. Increase the length to support upto 4KB.
Change-Id: I4a0a28044a54cdbde146101384f5a1ccf73b1562
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
QTI battery debug driver helps to get logs and debug information
by communicating with charger firmware (CHGFW) running on the
remote subsystem (e.g. DSP) over PMIC Glink. Currently, it
supports getting the device context dump of battery gauging
software which is part of CHGFW.
Change-Id: I7bb303cf61a97f3087f8c024fc6b37e68e5d1f1e
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This option enables the generation of debugfs files in PMIC GLINK client
drivers that are strictly meant for internal debugging only.
Change-Id: I0c0c27b38754dcc694a4b98d6cd29e4a78cd7426
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
The PMIC Glink driver provides the interface for clients to
communicate over GLink for sending and receiving data to charger
firmware that runs on a remote subsystem (e.g. ADSP) which
supports charging and gauging.
This enables clients to read/write battery charging parameters
and get notifications.
This is a snapshot taken as of msm-5.10
commit 0f4075248b75 ("soc: qcom: pmic_glink: Use
SERVREG_SERVICE_STATE_DOWN for handling PDR").
Change-Id: I1e4c09d1ee10c8c5397f4459afe8d656593d718a
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Signed-off-by: David Collins <collinsd@codeaurora.org>
Take a snapshot of the secure-buffer driver as of commit f843a80d2c45
("Merge "defconfig: gen3auto: Separated if_changed"") on msm-5.15.
secure_buffer.h is already merged.
Change-Id: I98cfe097d6b3b332a8a1a6ab2e42f090308585d3
Signed-off-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
Take a snapshot of the secure_buffer.h file as of commit f843a80d2c45
("Merge "defconfig: gen3auto: Separated if_changed"") on msm-5.15.
Change-Id: Ic6f1b59ead3bb2947d05ed3d2ea0eecf70597fe7
Signed-off-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
This is a snapshot of the minidump driver as of msm-5.15
commit <908a517b050d> ("Merge "sched/walt: remove duplicate
definitions of rt_task_arrival_time"").
Change-Id: I47eba0f9aedb1732724b94f567404287378c6189
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>
Add CONFIG_UFS_DBG option to support UFS debug features.
Change-Id: I98fb46223b74da587f265d96abd51526f0b488fd
Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
This is a snapshot of the soc watchdog, gunyah
watchdog and watchdog core driver as of msm-5.15
commit <908a517b050d> ("Merge "sched/walt: remove
duplicate definitions of rt_task_arrival_time"").
Change-Id: I78134e1b42e0abd74c3b4630c135715ee959afa1
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>
This is a snapshot of the qcom-dload-mode driver as of msm-5.15
commit <908a517b050d> ("Merge "sched/walt: remove duplicate
definitions of rt_task_arrival_time"").
Change-Id: I267e2ef3d4d86aba285e38d8b03ce5f3037d3c13
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>
This is a snapshot of the memory dump driver as of msm-5.15
commit <908a517b050d> ("Merge "sched/walt: remove duplicate
definitions of rt_task_arrival_time"").
Change-Id: If6fd016ee13340ec90cdd6f34bbc87293f5a39ee
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>
This is a snapshot of the socinfo driver as of msm-5.15
commit <908a517b050d> ("Merge "sched/walt: remove duplicate
definitions of rt_task_arrival_time"").
Change-Id: Ib969b851ccbfc5651259aba5872575d0fa3994db
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>
This is a snapshot of the cpu vendor hooks driver as of
msm-5.15 commit <908a517b050d> ("Merge "sched/walt: remove
duplicate definitions of rt_task_arrival_time"").
Change-Id: Ia878a0e8ac111bd6247382539a159f16f641de0a
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>
This is a snapshot of the qcom_logbuf_vendor_hooks as of
msm-5.15 commit <908a517b050d> ("Merge "sched/walt: remove
duplicate definitions of rt_task_arrival_time"").
Change-Id: I4e409c56acc59c38fcd7fdc10e03c3edb81ee1a3
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>
Enable downstream symbol trimming on mixed build. Will be partially
reverted once ACK has enabled symbol trimming.
Change-Id: Ia44da298809137b5def9ed14bfe3f4888bbca4b7
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>