summaryrefslogtreecommitdiff
path: root/common/acpi.c
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: add DPTF supportKeith Short2021-03-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | Add a Kconfig option to enable DPTF support. Adds support for the following ACPI entries: EC_ACPI_MEM_FAN_DUTY (0x04) EC_ACPI_MEM_TEMP_ID (0x05) EC_ACPI_MEM_TEMP_THRESHOLD (0x06) EC_ACPI_MEM_TEMP_COMMIT (0x07) BUG=b:179886912 BRANCH=none TEST=zmake testall TEST=Boot zephyr-ec on Volteer, observe that ACPI warnings for ignored read/writes for DPTF commands are fixed. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I40cbe79e57c3d4687d828ec46fe0d51034e96bfc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2757028 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
* retimer: support retimer firmware updateli feng2021-02-051-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support AP to update firmware during boot up, one byte EC RAM is allocated for AP <-> EC communication. AP queries PD port/requests EC to perform operations via EC_CMD_ACPI_WRITE; and fetches result from EC via EC_CMD_ACPI_READ. The flow is: 1. AP queries EC PD ports which port supports retimer firmware update. 2. AP queries current MUX. 3. a) If no device attached, AP requests EC to suspend PD task of the port. Then AP requests EC to set MUX to USB mode, Safe mode, TBT mode. After entering TBT mode, the OS can either enumerate the retimers or do firmware update on the enumerated retimers. Once done, AP requests EC to disconnect MUX and resume PD task. 3. b) If device attached, AP moves on as usual. Retimer firmware update is not performed. BUG=b:162528867 BRANCH=none TEST=Tested NDA case on Voxel board, together with coreboot and kernel changes. Coreboot changes are merged. Kernel patches list is: https://chromium-review.googlesource.com/c/chromiumos/ third_party/kernel/+/2670719 After power up, host scans retimers, in sysfs localhost ~ # ls /sys/bus/thunderbolt/devices/ 0-0 0-0:1.1 0-0:3.1 domain0 On PD port 1, manually update retimer firmware. Copy firmware to nvm_non_active1/nvmem, then authenticate it. Host starts flow to update firmware. After it's done, PD port 1 resumes. Hotplug DP dongle/TBT device, devices should function fully. TEST=Tested DA cases on Voxel board, together with coreboot and kernel changes. USB4/TBT devices function as usual. Signed-off-by: li feng <li1.feng@intel.com> Change-Id: Ie976e75f892d5caf48a948598a058a4f42e07eb3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2594492 Reviewed-by: Keith Short <keithshort@chromium.org>
* acpi: Align kblight ACPI behave the same as the host commandWai-Hong Tam2020-08-051-0/+1
| | | | | | | | | | | | | | | | | | The previous refactoring CL:2290831 aligns the kblight host command to act the same as the general PWM driver. But the kblight ACPI remains unchanged, that results a bug that the kblight is initially off and no way to enable it. Should align the kblight ACPI too. BRANCH=None BUG=b:162892223 TEST=Build the berknip board. Change-Id: I439dac642dc34335e2f5d277467789c94c1f8fef Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2338988 Reviewed-by: Aaron Durbin <adurbin@google.com>
* usb_port_power: move usb_port_enable[] to headerEdward Hill2020-03-201-4/+0
| | | | | | | | | | | | | | BUG=b:150349225 BRANCH=none TEST=none Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I0342239dacf3bfb5f50e5fe873805921fa4723a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2108332 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Paul Ma <magf@bitland.corp-partner.google.com> Tested-by: Paul Ma <magf@bitland.corp-partner.google.com> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* printf: Convert %T to %pTEvan Green2019-10-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | In order to be more compliant to standards, and ultimately turn on compile-time printf format validation, switch the non-standard %T into %pT, which takes a pointer to a 64-bit timestamp as an argument. For convenience, define PRINTF_TIMESTAMP_NOW, which will use the current time as the timestamp value, rather than forcing everyone to pass a pointer to get_time().val. For a couple of instances, simply use CPRINTS instead. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Cq-Depend:chrome-internal:1473305 Change-Id: I83e45b55a95ea27256dc147544ae3f7e39acc5dd Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704216 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* acpi: Notify AP when setting DPTF profile numberPhilip Chen2019-08-161-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Assuming a device without hall sensor is switched from clamshell mode all the way to 360-degree-flipped mode, the event sequence is like: (a) When the device hits 200-degree, it switches to tablet mode. (b) We notify AP to re-read DPTF profile from ACPI. (c) When the device hits 300-degree, it switches to 360-degree flipped mode and updates DPTF profile in EC space. Since the DPTF profile is switched in (c) while AP re-reads the DPTF profile in (b), AP wouldn't update DPTF profile for 360-degree-flipped mode. To fix this issue, let's notify AP when updating DPTF profile. BUG=b:139168228 BRANCH=none TEST=manually test on Nautilus/Hatch and confirm trip temperature is updated in flipped-360-degree mode Change-Id: I3bc61fb3d7808bf17f7da7ebc606307fbbf026fc Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1747166 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@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>
* kblight: Remove dependency on PWMDaisuke Nojiri2019-04-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | Keyboard backlight can be controlled either by PWM or an external controller. This patch decouples keyboard backlight common code and PWM based backlight control. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=Nami TEST=Verify keyboard backlight can be adjusted on Ekko. Change-Id: I332b01a2a2b15bd37ce385b6c30591c90f078dfc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1549476 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> (cherry picked from commit e879713cee3212b4afffb3f0dd3c4dfbf8237c4a) Reviewed-on: https://chromium-review.googlesource.com/1549606 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_port_power_smart: turn on/off charging mode during system suspendZhuohao Lee2019-01-301-1/+2
| | | | | | | | | | | | | | | | This patch adds a feature to allow the userspace program turns on/off the usb type-a charging mode during system suspend. BUG=b:121438672 BRANCH=firmware-rammus-11275 TEST=make -j buildall ectool usbchargemode 0 0x2 0, CDP works in S0 and S0ix ectool usbchargemode 0 0x2 1, CDP works in S0 but not in S0ix Change-Id: Icb8ab1b3f1beb671fbd02f441bf40284ba74e097 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1424040 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tablet_mode: Fix tablet mode for tablet devicesNicolas Boichat2018-12-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tablet devices would normally only define CONFIG_TABLET_MODE_SWITCH, and not CONFIG_TABLET_MODE, and define a tablet_get_mode function which always returns 1. Since 09a5e0a9398 "dptf: Get rid of CONFIG_DPTF_DEVICE_ORIENTATION", tablet_mode.h, when CONFIG_TABLET_MODE is not set, would define an _inline_ tablet_get_mode function which would always return 0, causing tablets to always be in laptop mode. Fix this by: - Removing the inline in tablet_mode.h. - Add CONFIG_TABLET_MODE to all our tablets (after removing the inline, compilation fails if CONFIG_TABLET_MODE_SWITCH is set, but not CONFIG_TABLET_MODE). - Remove tablet_get_mode from board/*/board.c, as the default mode is tablet, anyway. BRANCH=none BUG=b:120252451 TEST=Boot kukui, onscreen keyboard works TEST=No code size increase: build/kukui/RW/space_free_flash shrank by 36 bytes: (23968 to 23932) build/kukui/RW/space_free_ram shrank by 4 bytes: (10356 to 10352) build/rainier/RW/space_free_flash shrank by 36 bytes: (44296 to 44260) build/rainier/RW/space_free_ram shrank by 4 bytes: (12948 to 12944) build/scarlet/RW/space_free_flash shrank by 36 bytes: (28128 to 28092) build/scarlet/RW/space_free_ram shrank by 4 bytes: (10532 to 10528) Change-Id: Ifea0412bb32f1d701ad2040ad62a5c812705b14a Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1355645 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* dptf: Add support for DDPNFurquan Shaikh2018-11-151-1/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds Device DPTF Profile Number(DDPN) to EC_ACPI_MEM_DEVICE_ORIENTATION field to indicate to host which DPTF profile should be loaded depending upon the device mode. This is done to de-couple DPTF table loading from tablet mode flag to allow different drivers within EC to set the profile number depending upon their design. In order to maintain backward compatibility, this change treats 0 as reserved to indicate to host that it should fall back to using tablet mode switch to decide which DPTF table to load. Additionally, it provides helper function to allow drivers to set the profile number that will be returned on host query for EC_ACPI_MEM_DEVICE_ORIENTATION. It also adds a new config option CONFIG_DPTF_MULTI_PROFILE that should be selected by the boards that support multiple DPTF profiles on the host side. CQ-DEPEND=CL:1295852 BUG=b:117844490 BRANCH=None TEST=make -j buildall Change-Id: Idfa0cfea48b9df346533342647258474fb63e86c Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1295851 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@google.com>
* dptf: Get rid of CONFIG_DPTF_DEVICE_ORIENTATIONFurquan Shaikh2018-10-301-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CONFIG_DPTF_DEVICE_ORIENTATION was added to indicate mode change to the host to allow it to read the tablet mode flag from shared EC memory and select the right DPTF table to load (if supported). However, this config seems unnecessary because of the following reasons: 1. Host sets SCI mask to indicate to the EC which events it wants to process. Thus, even if the EC sets mode change flag, it will not be notified to the host unless it supports mode change event. 2. Additionally, if host supports mode change event, but does not support multiple DPTF tables, then EC ACPI code takes care of ensuring that there is a thermal event handler present to reload tables. 3. CONFIG_DPTF_DEVICE_ORIENTATION was defined for almost all new x86 boards. BUG=b:117844490 BRANCH=None TEST=make -j buildall Change-Id: Ic4097ae047e2d559673a321da4df86514f902993 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1292359 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* acpi: Return 0 for tablet mode if EC has no device orientationFurquan Shaikh2018-07-111-2/+4
| | | | | | | | | | | | | | | | | | | | | This change returns 0 for EC_ACPI_MEM_DEVICE_ORIENTATION if CONFIG_DPTF_DEVICE_ORIENTATION is not selected. This ensures that EC returns 0 for tablet mode since it does not know anything about device orientation. Returning 0xff can result in AP thinking that tablet mode is enabled since bit 0 is set indicating tablet mode. BUG=b:111264961 BRANCH=None TEST=Verified that on yorp input devices are not inhibited anymore with TBMC device enabled in coreboot. Change-Id: I69ec047813bf456e6ac81b1e1b10cd18b23250e4 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1132611 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* acpi: Add map for controlling USB port powerEmil Lundmark2018-05-291-0/+55
| | | | | | | | | | | | | | | | | | | Some devices have GPIO pins that control USB port power connected to the EC, so they cannot be toggled by ACPI. This patch adds a memory map between the EC and ACPI that can be used on such devices. It can hold the power state of up to 8 USB ports. Currently, only dumb power ports are supported. BUG=chromium:833436 BRANCH=fizz TEST=On a fizz that runs BIOS with EC_ACPI_MEM_USB_PORT_POWER mapped, check that both reads and writes are propagated. Change-Id: I413defcb9e4d234fea7f54d46b6b8a1a10efa31e Signed-off-by: Emil Lundmark <lndmrk@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1069273 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* kblight: Add keyboard backlight control moduleDaisuke Nojiri2018-05-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | This patch promotes board/nami/keyboard_backlight.c to common directory. Board customization is done via board_kblight_init callback. It currently supports two drivers: direct PWM control and lm3509. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:78360907,b:78141647 BRANCH=none TEST=On Nami (for lm3509) and Sona (pwm), verify the followings: 1. Alt + brightness up/down works 2. After suspend-resume, brightness is restored 3. Lid close/open 4. After screen is off, keyboard backlight is turned off Change-Id: I584c06e8702fe7b289999698f277311cfd3400bd Reviewed-on: https://chromium-review.googlesource.com/1051027 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* battery: Allow 2 batteries to be fetched via ACPINicolas Boichat2018-02-091-0/+7
| | | | | | | | | | | | | | | | | | | | | We share the same shared memory fields for both batteries. When the host wants to switch battery to read out: - The host sets EC_ACPI_MEM_BATTERY_INDEX to the required index - EC then swaps the data is the shared memory fields, then update EC_MEMMAP_BATT_INDEX - Host waits for EC_MEMMAP_BATT_INDEX to have the required value, then fetches the data BRANCH=none BUG=b:65697620 TEST=Boot lux, both /sys/class/power_supply/BAT0 and BAT1 are present, data is valid. TEST=Unplug base, BAT1 goes away, replug, BAT1 comes back. Change-Id: Icce12f9eef2f6f8cde9bae0a968a65e1703d0369 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/888382 Reviewed-by: Gwendal Grignou <gwendal@google.com>
* host_event: Move host events and mask handling into common codeFurquan Shaikh2017-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | Instead of duplicating the handling of host events and host event masks in chip lpc drivers, add routines in common code to provide basic functions like setting/getting of masks, setting/getting of events and handling of masks transitions across sysjump. BUG=None BRANCH=None TEST=make -j buildall. Verified following: 1. Event masks are correctly retained across sysjumps. 2. Wake from S3 works fine. 3. Wake from S0ix works fine. 4. SCI generated correctly. Change-Id: Ie409f91b12788e4b902b2627e31ba5ce40ff1d27 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/707771 Reviewed-by: Shawn N <shawnn@chromium.org>
* acpi: Map EC features into ACPI EC memory spacePatrick Georgi2017-08-301-0/+26
| | | | | | | | | | | | | | | | | Reserve EC address space offset 0x0a-0x0d for device features. Same value as with the host command, just different way to access it. BUG=b:64705535 BRANCH=none TEST=none Change-Id: I420aed1ae8d0fb7da477fc72ac55ea75a9f9350b Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/626976 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@google.com>
* common: Add tablet_mode APIGwendal Grignou2016-11-081-1/+2
| | | | | | | | | | | | | | | | | | | Simple API to set/get the tablet mode. It can be set via lid angle calculation or if a board has a dedicated HAL sensor/GPIO. Merged from glados branch, add MKBP switch support. BUG=chromium:606718 BRANCH=gru TEST=Check with Cave that both mode works. Reviewed-on: https://chromium-review.googlesource.com/402089 Reviewed-by: Shawn N <shawnn@chromium.org> (cherry picked from commit c940f36ceabcf2425284001298f03ebdb4c3079e) Change-Id: I2ee5130f3e0a1307ec3ea543f7a32d66bc32b31d Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/404915 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* Acpi: Notify host when orientation changesjames_chao2016-08-091-0/+7
| | | | | | | | | | | | | | | | | 1. EC send EC_HOST_EVENT_MODE_CHANGE(29/0x1D) when mode changes 2. Host read current "physical mode" from EC ERAM 3. Host Nodify DPTF object BUG=chrome-os-partner:53526 BRANCH=master TEST=make buildall Change-Id: I3ede1ffd203024199884b3a0c56347ae630e6062 Signed-off-by: james_chao <james_chao@asus.com> Reviewed-on: https://chromium-review.googlesource.com/363220 Commit-Ready: BoChao Jhan <james_chao@asus.com> Tested-by: BoChao Jhan <james_chao@asus.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* separate dptf logic from existing thermal logic.Ravi Chandra Sadineni2016-07-301-3/+3
| | | | | | | | | | | | | | | | Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org> BRANCH=none BUG=chromium:631848 TEST=make buildall -j Change-Id: I718a29b067d37af477306f9bebfcb8e71d84d4ee Reviewed-on: https://chromium-review.googlesource.com/363008 Commit-Ready: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@google.com>
* Deferred: Use deferred_data instead of function pointerAnton Staaf2016-04-181-2/+2
| | | | | | | | | | | | | | | | | | | | | 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>
* common: acpi: Add items to .bss.slow.Aseda Aboagye2015-11-091-6/+10
| | | | | | | | | | | | | | | | | | | | BUG=chrome-os-partner:46056 BUG=chrome-os-partner:46063 BRANCH=None TEST=Enabled CONFIG_REPLACE_LOADER_WITH_BSS_SLOW on GLaDOS; Build and flash; Verify that AP and EC boot. Verify that AC notifications are sent to the AP. Verify that I can set temperature thresholds. TEST='sysjump rw' and repeat above tests. TEST=make -j buildall tests CQ-DEPEND=CL:311209 Change-Id: If2a7b0ce08b37e30362ab77eee1317c8a86b90dd Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/311344 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* acpi: Ensure continuity of memmap data with a read cacheShawn Nematbakhsh2015-07-281-41/+72
| | | | | | | | | | | | | | | | | | | | | For multi-byte ACPI memmap reads, we previously had a mutex to ensure data continuity. A better approach is to use a read cache. Since the kernel will enable burst mode before reading a multi-byte memmap variable and disable it afterward, we can populate the cache on the first read after enabling burst. This solution removes deadlock bugs, is contained entirely in acpi.c, and saves a deferred function. BUG=chromium:514283 TEST=Manual on Glados. Add prints in acpi_read, verify that multi-byte reads come from cache and non-burst reads continue to function as before. BRANCH=Cyan Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I74e4927bf2b433e31a9ff65d72820fa087c51722 Reviewed-on: https://chromium-review.googlesource.com/288871 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Fix assertion crash in __wait_evt()Chiranjeevi Rapolu2015-06-251-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | mutex_lock() is called from MEC1322_IRQ_ACPIEC0_IBF interrupt context, causing deadlock and assertion in __wait_evt(). In the interrupt context it now checks for mutex lock first. If the mutex is already locked,, it will disable ACPI interrupts and defer the memmap mutex lock. Added LPC interrupt disable/enable functions as needed. Increased deferred function count where needed. BRANCH=None BUG=chrome-os-partner:40820 TEST=Test for suspend-resume, cold, warm reboots and other general stability. Change-Id: I3dda0d4635a6b6281faf200c8c7b6fcba8877254 Signed-off-by: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com> Reviewed-on: https://chromium-review.googlesource.com/280418 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Commit-Queue: Divya Jyothi <divya.jyothi@intel.com> Tested-by: Divya Jyothi <divya.jyothi@intel.com>
* ACPI: Support accessing memmap data over ACPI CMD / DATA portsstabilize-6915.BShawn Nematbakhsh2015-03-251-6/+45
| | | | | | | | | | | | | | | | | | | | | | | Some platforms are unable to access the 900h-9ffh region over LPC and must instead access memmap data through the ACPI CMD / DATA ports. To avoid racing with data updates, disallow changes to multi-byte memmap data while in burst mode. Linux currently enables burst mode when accessing multi-byte data and disables it immediately afterward, though the ACPI spec defines burst mode in a more general way. BUG=chrome-os-partner:38224 TEST=Manual on Samus. Undefine LPC_MEMMAP and modify asl to move memmap data to ERAM at offset 0x20. Verify system boots cleanly and battery status is updated immediately on plug / unplug. BRANCH=None Change-Id: Ib848bdb491fdfece96ad0cee7a44ba85b4a1a50b Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/262072 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* Add cprints() and ccprints()Vic Yang2014-05-211-3/+4
| | | | | | | | | | | | | | | | | | | | | Our code base contains a lot of debug messages in this pattern: CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n") The strings are taking up spaces in the EC binaries, so let's refactor this by adding cprints() and ccprints(). cprints() is just like cprintf(), except that it adds the brackets and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...) This saves us hundreds of bytes in EC binaries. BUG=chromium:374575 TEST=Build and check flash size BRANCH=None Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200490 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Support DPTF charger current limitingRandall Spangler2014-02-081-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This enables the AP to limit charging current via ACPI. BUG=chrome-os-partner:23971 BRANCH=rambi TEST=manual drain battery down to <90%, then plug into AC (charger commands at EC console, iotools at root shell) iotools io_write8 0x66 0x81 iotools io_write8 0x62 0x08 iotools io_write8 0x62 3 charger -> dptf limit 192, I_batt=192 charger dptf 320 charger -> dptf limit 320, I_batt=320 iotools io_write8 0x66 0x80 iotools io_write8 0x62 0x08 iotools io_read8 0x62 -> 0x05 iotools io_write8 0x66 0x81 iotools io_write8 0x62 0x08 iotools io_write8 0x62 0xff charger -> dptf disabled, I_batt=(something > 192) iotools io_write8 0x66 0x80 iotools io_write8 0x62 0x08 iotools io_read8 0x62 -> 0xff Change-Id: Iace2ebbbc018143c0154310d7acd02d16a6b7339 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/185411 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Let AP read sensor IDs when DPTF thermal thresholds crossedBill Richardson2013-12-161-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spec does not mandate any way to read back the threshold settings themselves, but when a threshold is crossed the AP needs a way to determine which sensor(s) are responsible. Each reading of the EC_ACPI_MEM_TEMP_ID register clears and returns one sensor ID that has crossed one of its thresholds (in either direction) since the last read. A value of 0xFF means "no new thresholds have tripped". Changing or enabling the thresholds for any sensor will clear the unread event count for that sensor. BUG=chrome-os-partner:23970 BRANCH=none TEST=manual On the host, set a couple of thresholds to low values so they trip immediately (I'm testing on Link): # dptf() { [ "$#" -eq "2" ] || return; iotools io_write8 0x66 0x81 iotools io_write8 0x62 $1 iotools io_write8 0x62 $2 } # # dptf 5 0 # dptf 6 10 # dptf 7 3 # dptf 5 2 # dptf 6 10 # dptf 7 2 On the EC console, see that two thresholds have triggered, and that there are two bits set in the AP seen mask: [45.755365 DPTF sensor 0, threshold -63 C, index 1, enabled] [45.768940 DPTF sensor 2, threshold -63 C, index 0, enabled] [46.169490 DPTF over threshold [0][1] [46.169820 DPTF over threshold [2][0] > dptftemp sensor thresh0 thresh1 0 --- 210* I2C-USB C-Die 1 --- --- I2C-USB C-Object 2 210* --- I2C-PCH D-Die 3 --- --- I2C-PCH D-Object 4 --- --- I2C-Hinge C-Die 5 --- --- I2C-Hinge C-Object 6 --- --- I2C-Charger D-Die 7 --- --- I2C-Charger D-Object 8 --- --- ECInternal 9 --- --- PECI AP seen mask: 0x00000005 > Read the EC_ACPI_MEM_TEMP_ID register from the host, to get the two active sensor IDs (0 and 2), then 0xff when those are seen. # iotools io_write8 0x66 0x80; iotools io_write8 0x62 5; iotools io_read8 0x62 0x00 # iotools io_write8 0x66 0x80; iotools io_write8 0x62 5; iotools io_read8 0x62 0x02 # iotools io_write8 0x66 0x80; iotools io_write8 0x62 5; iotools io_read8 0x62 0xff # iotools io_write8 0x66 0x80; iotools io_write8 0x62 5; iotools io_read8 0x62 0xff # Change-Id: I8f047a517357617f18ad59d21fa13409bc81821b Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/180224 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add stubs for DPTF thermal thresholdsBill Richardson2013-12-131-17/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds three new registers to the ACPI->EC interface, which will allow the AP to set/clear two DPTF thermal threshold points for each temp sensor. The registers are EC_ACPI_MEM_TEMP_ID 0x05 EC_ACPI_MEM_TEMP_THRESHOLD 0x06 EC_ACPI_MEM_TEMP_COMMIT 0x07 It doesn't actually do anything yet, but the AP can now write those values. BUG=chrome-os-partner:23970 BRANCH=none TEST=manual On the host: dptf() { [ "$#" -eq "2" ] || return; iotools io_write8 0x66 0x81 iotools io_write8 0x62 $1 iotools io_write8 0x62 $2 } Now watch the EC console while running on the host: dptf 5 1 dptf 6 80 dptf 7 2 dptf 7 3 The EC should say DPTF sensor 1, threshold 7 C, index 0, enabled DPTF sensor 1, threshold 7 C, index 1, enabled Change-Id: I71fa57e3ca7c7b5bb8892e63212bf294b44dece5 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/179778 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Move ACPI stuff out of chip/lm4 and into commonBill Richardson2013-12-121-0/+132
The port 62/66 ACPI commands were implemented in chip/lm4/lpc.c. They should be handled in common instead of being tied to a particular EC. BUG=chrome-os-partner:23774 BRANCH=none TEST=manual read EC_ACPI_MEM_VERSION # iotools io_write8 0x66 0x80; iotools io_write8 0x62 0; iotools io_read8 0x62 0x01 write & read EC_ACPI_MEM_TEST # iotools io_write8 0x66 0x81; iotools io_write8 0x62 1; iotools io_write8 0x62 0xa5 # iotools io_write8 0x66 0x80; iotools io_write8 0x62 1; iotools io_read8 0x62 0xa5 # iotools io_write8 0x66 0x80; iotools io_write8 0x62 2; iotools io_read8 0x62 0x5a # iotools io_write8 0x66 0x81; iotools io_write8 0x62 1; iotools io_write8 0x62 0xbb # iotools io_write8 0x66 0x80; iotools io_write8 0x62 1; iotools io_read8 0x62 0xbb # iotools io_write8 0x66 0x80; iotools io_write8 0x62 2; iotools io_read8 0x62 0x44 read & write EC_ACPI_MEM_KEYBOARD_BACKLIGHT # iotools io_write8 0x66 0x81; iotools io_write8 0x62 3; iotools io_write8 0x62 100 (keyboard lights up) # iotools io_write8 0x66 0x80; iotools io_write8 0x62 3; iotools io_read8 0x62 0x64 # iotools io_write8 0x66 0x81; iotools io_write8 0x62 3; iotools io_write8 0x62 50 (keyboard dimmer) # iotools io_write8 0x66 0x80; iotools io_write8 0x62 3; iotools io_read8 0x62 0x32 # iotools io_write8 0x66 0x81; iotools io_write8 0x62 3; iotools io_write8 0x62 0 (keyboard goes dark) # iotools io_write8 0x66 0x80; iotools io_write8 0x62 3; iotools io_read8 0x62 0x00 read & write EC_ACPI_MEM_FAN_DUTY # iotools io_write8 0x66 0x81; iotools io_write8 0x62 4; iotools io_write8 0x62 100 (fan on full) # iotools io_write8 0x66 0x80; iotools io_write8 0x62 4; iotools io_read8 0x62 0x64 # iotools io_write8 0x66 0x81; iotools io_write8 0x62 4; iotools io_write8 0x62 50 (fan on half speed) # iotools io_write8 0x66 0x80; iotools io_write8 0x62 4; iotools io_read8 0x62 0x32 # iotools io_write8 0x66 0x81; iotools io_write8 0x62 4; iotools io_write8 0x62 0 (fan off) # iotools io_write8 0x66 0x80; iotools io_write8 0x62 4; iotools io_read8 0x62 0x00 # iotools io_write8 0x66 0x81; iotools io_write8 0x62 4; iotools io_write8 0x62 0xff (fan back to EC control) # iotools io_write8 0x66 0x80; iotools io_write8 0x62 4; iotools io_read8 0x62 0xff test EC_CMD_ACPI_QUERY_EVENT # iotools io_write8 0x66 0x84; iotools io_read8 0x62 0x00 On EC console: > hostevent set 0x0f000000 # ectool eventget Current host events: 0x0f000000 # iotools io_write8 0x66 0x84; iotools io_read8 0x62 0x19 # iotools io_write8 0x66 0x84; iotools io_read8 0x62 0x1a # iotools io_write8 0x66 0x84; iotools io_read8 0x62 0x1b # iotools io_write8 0x66 0x84; iotools io_read8 0x62 0x1c # iotools io_write8 0x66 0x84; iotools io_read8 0x62 0x00 # ectool eventget Current host events: 0x00000000 Change-Id: I011a5a2051171ec1d37e55ce03e1ce74b93a7e14 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/179692