summaryrefslogtreecommitdiff
path: root/common/extpower_gpio.c
Commit message (Collapse)AuthorAgeFilesLines
* extpower: Add helper function extpower_handle_updateFurquan Shaikh2020-06-121-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds a helper function extpower_handle_update() that performs all the necessary actions that need to be done on external power state change: 1. Call hook_notify with AC_CHANGE 2. Update memmap_batt_flags to update EC_BATT_FLAG_AC_PRESENT 3. Set host event for EC_HOST_EVENT_AC_CONNECTED or EC_HOST_EVENT_AC_DISCONNECTED. Step#2 above is important because it ensures that the memory map flag is correctly updated when host reads it. Before this change, it was observed that EC_BATT_FLAG_AC_PRESENT is updated only when static/dynamic battery information gets updated. This could result in host reading the wrong AC state if battery information did not update before host acts on the host event bit getting set for AC connect/disconnect. BUG=b:157752693 BRANCH=None TEST=Verified on trembyle that EC ASL routines read the correct state of AC present flag on receiving host event. Signed-off-by: Furquan Shaikh <furquan@google.com> Change-Id: I077de1135320654f571e5cf87ced6f08cbf23876 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242353 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Auto-Submit: Furquan Shaikh <furquan@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* extpower: Allow board to override signal debounce timeDavid Hendricks2016-09-021-3/+2
| | | | | | | | | | | | | | | | This is for boards on which AC_PRESENT can be expected to fluctuate over a much longer period than the code was originally designed for. Specifically, USB-PD systems may require several hundred milliseconds for the state machine to settle before making decisions based on AC_PRESENT status, for example, changing LED state. BUG=chrome-os-partner:56471 BRANCH=none TEST=Tested on Reef with follow-up patch Change-Id: I370048cb79d1593a14077563ec8db8e8282afb16 Signed-off-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/378755
* Deferred: Use deferred_data instead of function pointerAnton Staaf2016-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | | Previously calls to hook_call_deferred were passed the function to call, which was then looked up in the .rodata.deferred section with a linear search. This linear search can be replaced with a subtract by passing the pointer to the deferred_data object created when DECLARE_DEFERRED was invoked. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None CQ-DEPEND=CL:*255812 TEST=make buildall -j Change-Id: I951dd1541302875b102dd086154cf05591694440 Reviewed-on: https://chromium-review.googlesource.com/334315 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Initialize the memory-mapped AC_PRESENT flagTed Kuo2015-05-281-0/+8
| | | | | | | | | | | | | | | | | | | The memory-mapped AC_PRESENT flag needs to be initialized for the batteryless projects. BUG=chrome-os-partner:40384 TEST=make -j buildall, make -j tests BRANCH=None Signed-off-by: Ted Kuo <tedkuo@ami.com.tw> Change-Id: Ia64ad6564f99b4aae060d29a572b4fe173da62d9 Reviewed-on: https://chromium-review.googlesource.com/273082 Tested-by: Ted Kuo <tedkuo@ami.com.tw> Reviewed-by: Mohammed Habibulla <moch@google.com> Commit-Queue: Ted Kuo <tedkuo@ami.com.tw> (cherry picked from commit 6cc0ece36d4190e2461f7e44767e0f77f47401b8) Reviewed-on: https://chromium-review.googlesource.com/273462 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Initialize extpower module prior to modules with default priorityChromeOS Developer2014-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This ensures that modules with default priority (or later) get an accurate response from extpower_is_present(). BUG=chrome-os-partner:27160 BRANCH=ToT TEST=Add a default priority initializer. Verify it gets the correct value for extpower_is_present() with and without external power connected. static void extpower_init_check(void) { CPRINTF("[%T Extpower %s]\n", extpower_is_present() ? "on" : "off"); } DECLARE_HOOK(HOOK_INIT, extpower_init_check, HOOK_PRIO_DEFAULT); Change-Id: Ic47c79d3ab4e7b2fdb6ad2354e4f455697cac250 Original-Change-Id: I13edc32b2a4609fad12982fd710fa95f9e81c9c2 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191296 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/192137
* Debounce external power change eventsChromeOS Developer2014-03-291-3/+16
| | | | | | | | | | | | | | | | BUG=chrome-os-partner:26838 BRANCH=ToT TEST=Verify only one ACPI 4 event is generated when attaching external power and that only one ACPI 5 event is generated when removing external power. (using the ec console) Change-Id: I7f8efa03a18bda39152abc2326f1cda928355868 Original-Change-Id: Icaec298bd0f41708260117c26f83fe9158a7ad4e Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/189930 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/192135
* Move enabling AC_PRESENT interrupt to extpower_gpio.cRandall Spangler2013-04-021-0/+7
| | | | | | | | | | | | | | The interrupt handler moved a while ago, but the code to enable the interrupt at init-time didn't. Fix that. BUG=chrome-os-partner:18256 BRANCH=none TEST=boot system. unplug AC. replug AC. UI charging indicator should update. Change-Id: Ie16aa7f6eb9e871a6e3e8ecf6733ecbdc883be0b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47041 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Add support for calling deferred functionsRandall Spangler2013-04-021-4/+7
| | | | | | | | | | | | | | | | | This is a cleaner way of deferring work from interrupt-time to task-time without requiring a task for each module which needs this. Replaces/supersedes delayed hook notification, which didn't scale well (since every function would have needed to be its own hook type). BUG=chrome-os-partner:18473 BRANCH=none TEST=boot system. plug/unplug AC power; notifies the host properly Change-Id: I50263fe1ce37e74c1ef8db3671379098997102ed Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46953 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Move external power detect for link to its own fileChromeOS Developer2013-03-191-0/+35
Now that it doesn't need to leverage SWITCH_TASK to send the AC_CHANGE notification, pure GPIO-based external power detection can move from switch.c to its own file. BUG=chrome-os-partner:18256 BRANCH=none TEST=add AC power, UI shows charging indicator; remove AC, indicator goes away Change-Id: Id495f34185b7d971c241ac6d0a8311a6bf544507 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/45789