summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* Nami: Make Vayne cutoff battery on critical chargeDaisuke Nojiri2019-03-061-0/+10
| | | | | | | | | | | | | | | | | | | | Currently, Vayne and all other Nami's hibernate when battery is at critical level for 30 seconds. This patch makes Vayne cutoff the battery at critical charge. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/123727148 BRANCH=nami TEST=Verify Vayne shuts down on critical battery then battery is cutoff in 30 seconds. Verify AC plugin boot DUT on both ports. Change-Id: I1da572669c7fbe00753668810692d73ffe9f4bf8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1504076 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* npcx: pwm: Use DCRn greater than CTRn to present its duty cycle is zero.Mulin Chao2019-03-063-21/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In npcx pwm driver, it turns off pwm module directly when its duty cycle is set to zero. But we saw pwm signal isn't turned off by the following sequence: 1. pwm_set_raw_duty(ch, 0); 2. pwm_enable(ch, 1); Please notice setting zero in DCRn doesn't mean duty cycle is zero. (NPCX duty cycle: ( (DCRn+1) / (CTRn+1) ) x 100). Hence in step 2, we can observe a very low duty cycle once the driver enables pwm module. According to figure. 24 in npcx5's datasheet, setting DCRn greater than CTRn means that the result of 16-bits comparator is always false. It equals the duty cycle is zero. This CL adopts this method to present it and removes the dependency between pwm_enable()/ pwm_get_enabled() and pwm_set_raw_duty()/pwm_get_duty(). In order to make sure DCRn can be greater than CTRn, we also defined the PWN maximum duty cycle is (0xFFFF -1) since both DCR and CTR are 16-bits registers. BRANCH=none BUG=b:123552920 TEST=No build errors for npcx5/7 series. Test pwm console command on npcx5/7 evbs by the following sequence. 1. pwm_set_raw_duty(ch, 0); 2. pwm_enable(ch, 1); And no symptoms are observed. PWM_CONFIG_ACTIVE_LOW flag is tested also and no symptom occurred. Test fan control by faninfo & fanset console commands. Connect Sunon 4-pins PWM fan and evb by following steps: 1. Connect PWM0 to PWM pin of fan. 2. Connect TA1_TACH1 and 3.3 PU on Tacho pin of fan. 3. Connect 5V and GND pins of fan to power supply. No symptoms are observed. Change-Id: I92517ff0bf3e027ae191be00112cd71ec4b55a2b Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/1475096 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> (cherry picked from commit 93d7bcea8121869520b0d02bf94f95eb261bee05) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1490675 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* chgstv2: Make board_critical_shutdown_check specify action on critical socDaisuke Nojiri2019-03-054-10/+57
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, board_critical_shutdown_check is used only in the context of CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF. It returns true to cutoff the battery or false to take no action. This patch extends board_critical_shutdown_check to allow it to control what actions to take on critical battery condition. With this change, each board can also customize critical battery actions with more granularity (per OEM, BOARD_VERSION, etc.). Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/123727148 BRANCH=nami TEST=Verify a battery is cutoff at critical low charge on Scarlet and DUT wakes up by AC plugin on cros/firmware-scarlet-10388.B. Change-Id: Id49e860b05e21c3bfa4d75f27c48b55c2a3ad95f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1504075 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* bmi160: do not overrun the amount of data read from the BMI FIFOEnrico Granata2019-02-121-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a race condition in the BMI160 driver w.r.t. reading from the FIFO. The previous code was reading the FIFO length, adding 1 byte to it and then reading that much data into a static buffer. This works well if no new samples are added to the FIFO between reading the length and reading the payload. But, if the BMI pushes a new sample in the FIFO, the read will not return an empty frame header, but instead fill in the first byte of the new sample, which is - however - incomplete and will be retransmitted. However, because the buffer we process is static, if things align just right, it is possible for that header to be parsed as a valid sample, since we do not clear the buffer and we assume the entire 64 bytes of it are valid and processable. Fix this issue by maintaining a pointer to the end of the read-in FIFO buffer and using that - instead of the static bp + sizeof - to calculate how much data we can actually process from the FIFO. BUG=b:120508077 BRANCH=poppy,octopus TEST=Starting from CL:1367013 and CL:1370689, adding an `msleep(2)` between reading last_interrupt_timestamp and calling load_fifo(), observe that the kernel sees more sensor events than should be present given the sample rate selected. Observe that some of those have repeated payload values. With this change, the number of samples seen at the kernel side is compatible with the chosen sample rate and no samples have incorrectly repeating payloads. It is possible to also make this more obvious by setting the buffer to contain an incorrect value before reading from the FIFO, and observing that no samples contain that incorrect value. Conflicts: driver/accelgyro_bmi160.c: cherry-pick on top of an older version of driver: bmi160: Read the FIFO more efficiently: CL:1150741 Change-Id: I57124756d51b8acf04630020c1ffb934f471735f Signed-off-by: Enrico Granata <egranata@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1372027 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org> (cherry picked from commit adc5c0f3159c10e81904fc68be7b09b2ef5e3c19) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1387601
* bmi160: Keep timestamp and FIFO synchronizedEnrico Granata2019-02-121-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BMI160 will clear the FIFO watermark/full interrupt when the FIFO crosses the threshold condition - which happens upon reading from it in load_fifo(). As a result of this, and the fact that the soft IRQ handler for the BMI160 tries to loop until it has finished serving all interrupt causes, there are possibilities for a race condition such as the following to occur: read timestamp, value is t0 read interrupt cause: it's a watermark interrupt load fifo(t0): this clears the interrupt, allowing a new one to happen read timestamp, value is still t0 a watermark interrupt happens at t1 read interrupt cause: watermark load fifo(t0) At this point, the fifo will process events at t1 as-if they had happened at t0, which is bad and causes incorrect timestamps on the AP side. This changes moves reading the timestamp value as close as possible to load_fifo, and in a relative order where a new watermark interrupt cannot happen, which ensures the timestamp and the FIFO data for it are synchronized BUG=b:120508077 TEST=on Bobba and Nocturne, observe that no events happen where an identical "a" time matches two distinct (b,c) times BRANCH=nocturne,bobba Change-Id: I454b257366bccf2b9e4d78df5dc005a8ad7313a0 Signed-off-by: Enrico Granata <egranata@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1367013 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> (cherry picked from commit e5fc358df19e1c4147d35749b6ddf91e22cebbf2) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1387600
* bmi160: exit IRQ loop if error during reg readJett Rink2019-02-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | The IRQ handler for bmi160 continues to loop until all of the interrupt reasons are handled; however, if the read fails the interrupt variable will be in an unknown state. We can either return early if there was an error or we can set the interrupt variable to 0 before the read call. Either way the loop exits. BRANCH=none BUG=b:119093572 TEST=On Bobba360 with a solid repro case of the watchdog reset, this change avoids the watchdog reset. Change-Id: I482f074b6e9e7c183def8ce17157ed28ca96b1c9 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1378908 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Enrico Granata <egranata@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> (cherry picked from commit 4d15f8668fbadac39604c6e015a86c1634162584) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1387599 Commit-Queue: Enrico Granata <egranata@chromium.org> Tested-by: Enrico Granata <egranata@chromium.org>
* FIXUP: driver: bmi160: harden interrupt and fifo processingGwendal Grignou2019-02-121-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Actually 5ms is needed to reset interrupt of activity like significant motion. When processing FIFO, the interrupt will go down once the FIFO is processed, but for activity, there is no easy way for the bit to go down. See https://electronics.stackexchange.com/questions/299188/how-to-program-bmi160-inertial-measuremen-unit-to-latch-detection-flags BUG=b:73557414,b:80284952 BRANCH=scarlet,poppy,nocturne TEST=Without this change, the interrupt bitfield in the the interrupt routine never goes back to 0. Check the sensor is not getting stuck. Change-Id: I986547787183377938ab08afe52fb2871d5c7c71 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1205203 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 61b1806c0db895487ee9e687f365d844f5931732) Reviewed-on: https://chromium-review.googlesource.com/1252449 (cherry picked from commit 01fcc3ec9da695f4db0b631b1f9a96dd462cfcc6) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1387598 Reviewed-by: Enrico Granata <egranata@chromium.org> Commit-Queue: Enrico Granata <egranata@chromium.org> Tested-by: Enrico Granata <egranata@chromium.org>
* bmi160: End IRQ handler if sensor isn't powered.Aseda Aboagye2019-02-121-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | It's possible for the interrupt to be triggered and then when the bottom half of the interrupt handler gets a chance to run, the sensor isn't powered anymore. This commit simply has the loop terminate early if the board indicates that the bus the sensor is on is no longer powered. BUG=b:111683988 BRANCH=nocturne TEST=Verify if IRQ handler is called when sensor is not powered, the irq_handler loop terminates. Change-Id: Iaf395902bb4b46a5b6d750c99767c4c36b1e7a99 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1182879 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org> (cherry picked from commit 08f3d2d701b8c78ecbb51c8e48aabf5ad56d4be9) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1387597 Reviewed-by: Enrico Granata <egranata@chromium.org> Commit-Queue: Enrico Granata <egranata@chromium.org> Tested-by: Enrico Granata <egranata@chromium.org>
* Ekko/Bard: Setting input current limit to 95%Sue Chen2019-02-111-1/+5
| | | | | | | | | | | | | | | | | AC adapter Input current limit exceeds maximum current =3.049A. We need to set lower input current limit to make sure safety confirm test pass. BUG=b:123063172 BRANCH=firmware-nami-10775.B TEST=Safety measure AC Adapter Rating PASS Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Change-Id: I4587cfac9ac9e18bcab9f3b42ed5964cb6e3fc8e Reviewed-on: https://chromium-review.googlesource.com/c/1424038 Commit-Queue: Sue Chen <sue.chen@quanta.corp-partner.google.com> Tested-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Revert "USB-PD: Debounce when trying try.src"Daisuke Nojiri2019-02-011-13/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 7ad2c6b1aed61142350fba303e04ea628ced33d0. Reason for revert: b/123173719. Original change's description: > USB-PD: Debounce when trying try.src > > Currently, if try.src is enabled, the TCPM doesn't debounce for > SNK connection. > > This patch makes the TCPM wait for tPDDebounce when detecting > SNK connection after switching from SNK to SRC for try.src. > > BUG=b:115464001 > BRANCH=none > TEST=On Sona, verify picture is shown on HP s240.via USB-C > TEST=On Sona, verify picture is shown on HP s240 via Hoho. > > Change-Id: I4f91bfca4f829f051d1c33f88f3664fad9b83e9f > Reviewed-on: https://chromium-review.googlesource.com/1297035 > Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> > Tested-by: Daisuke Nojiri <dnojiri@chromium.org> > Reviewed-by: Jett Rink <jettrink@chromium.org> > (cherry picked from commit 8641a3876fb60bec2faf548c7baa53a562943c56) > Reviewed-on: https://chromium-review.googlesource.com/c/1297033 > Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> > Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Bug: b:115464001 Change-Id: I25838989d411fcd3383cff13d35d28cfba024444 Reviewed-on: https://chromium-review.googlesource.com/c/1448814 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Set DP EQ level compensation up to 3.6dB for SonaDaisuke Nojiri2019-01-241-2/+12
| | | | | | | | | | | | | | | | | This patch sets DP EQ level compensation up to 3.6dB to avoid flicker or no picture for Sona and Sona-G7. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/122707483 BRANCH=nami TEST=buildall Change-Id: Ib7d64d1bcde9b5e0996e9be9fb68548b0d0df9c6 Reviewed-on: https://chromium-review.googlesource.com/c/1407230 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* BC1.2: Add usb_charger_reset_charge APIDaisuke Nojiri2019-01-243-23/+25
| | | | | | | | | | | | | | | | | | | This patch adds the sub_charger_reset_charge API, which resets the voltage and the current for all BC 1.2 supplies. This reduces code duplication. There is no functionality changes. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: I21afaff9a3c66b1a81ab5c907e6cdd1f1b3896a0 Reviewed-on: https://chromium-review.googlesource.com/c/1400154 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* PI3USB9238: Read device type and charge registers after INTB assertionDaisuke Nojiri2019-01-242-42/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | PI3USB9238 can fail to detect BC 1.2 charger because the initialization timing after reset differs chip to chip. This patch checks the interrupt register in a loop to wait until device type and charger status registers are ready. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/119166282 BRANCH=nami TEST=Verify BC 1.2 chargers are reliably detected as DCP (wall-charger), CDP (type-A port on chromebook), and SDP (type-c port on chromebook) by type-c port of Vayne (via A-to-C cable). Change-Id: I970007723fcff5e2818765705d534d1a581b33e7 Reviewed-on: https://chromium-review.googlesource.com/1399202 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit c7db1b252418b36a6a0ec619b45ad0aa443af3c8) Reviewed-on: https://chromium-review.googlesource.com/c/1395757 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* Battery: Force data update for EC_CMD_BATTERY_GET_STATICDaisuke Nojiri2019-01-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Currently, EC_CMD_BATTERY_GET_STATIC reads static data which was updated previously. Since static data is updated only on special conditions, it causes the command to return stale data. This change makes the command force data update. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:117938291 BRANCH=none TEST=buildall Change-Id: I7acdfe5bac5ab87001ee57bd053c7cef411dfdd1 Reviewed-on: https://chromium-review.googlesource.com/1302834 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit cc80d2bed27d5fee1cf046641c64b7dd2a12e00c) Reviewed-on: https://chromium-review.googlesource.com/c/1413773 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: support factory keyboard test.Sue Chen2019-01-142-0/+23
| | | | | | | | | | | | | | | | | | | | | | connector-to-GPIO map: {-1, -1}, {0, 5}, {1, 1}, {1, 0}, {0, 6}, {0, 7}, {-1, -1}, {-1, -1}, {1, 4}, {1, 3}, {-1, -1}, {1, 6}, {1, 7}, {3, 1}, {2, 0}, {1, 5}, {2, 6}, {2, 7}, {2, 1}, {2, 4}, {2, 5}, {1, 2}, {2, 3},{2, 2}, {3, 0}, {-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}, BUG=b:115819549 BRANCH=nami TEST=`ectool kbfactorytest` PASS. Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Change-Id: I4f3a72d41c37cf752a470df430b36cf0a5d58400 Reviewed-on: https://chromium-review.googlesource.com/c/1304153 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com> Tested-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
* cheza: Mux the 1st-plugged UFP port which is not a chargerWai-Hong Tam2019-01-086-4/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are 2 USB-C ports. A user may plug a USB-C to USB-A male cable to one of the ports; then EC should mux the port from USB hub to AP's primary USB controller, which is configured to do USB peripheral mode only. The policy is to mux the first-plugged UFP port to AP, with the following exception: * If the partner port does PD and it advertises the USB communications capable bit unset in the fixed-supply PDO, we believe the partner port is a pure charger. * If the BC1.2 chip detects the partner is not a SDP or CDP , we believe the partner port is not a workstation. Check the design doc at: http://go/cheza-hs-mux BRANCH=none BUG=b:74395451, b:110803836 TEST=Check the following scenario: * Plug charger w/ PD to P0, plug C-to-A to P1, check P1 mux to AP. * Plug charger through hub to P0, plug C-to-A to P1, check P1 mux to AP. * Continue the above case, boot into kernel and check USB peripheral mode. * Plug BC1.2 charger to P0, plug C-to-A to P1, check P1 mux to AP. * Plug charger w/o PD to P0, plug C-to-A to P1, check P0 mux to AP. * Swap P0 and P1 for the above cases and check the results. Change-Id: I4034fa66c0b27cc48d0959bb3f1750690ad5e3f7 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/1105404 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1400153 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* chgmgr: Allow charge_manager_update_charge to accept NULLDaisuke Nojiri2019-01-0810-61/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, charge_manager_update_charge does not handle NULL pointer for struct charge_port_info any differently. It's not sanity-checked either (thus memory access violation can occur). This patch will make charge_manager_update_charge accept NULL pointer and set available current and voltage to zero. This also helps callers' intentions be clear because callers can explicitly specify NULL (instead of passing a pointer to chg = {0}, which is initialized somewhere else). Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: I518662ab6a3a07f93da5d34cf62a6f856884f67d Reviewed-on: https://chromium-review.googlesource.com/1226125 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1400152 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* chgmgr: Set available voltage to 0 on disconnectDaisuke Nojiri2019-01-087-29/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, available current is consistently set to zero when a supplier is disconnected across BC 1.2 drivers, PD task, usb charger task but voltage is set to zero only in some places. This patch will set available voltage consistently to 0 on disconnected ports. This change should have no impact externally or internally because currently ports are treated as a disconnected port as long as available current is zero. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:841944 BRANCH=none TEST=Verify ectool usbpdpower 1 return 'Port 1: Disconnected' and 'Port 1: SNK (not charging)' without and with a BJ adapter connected respectively on Fizz. Verify ectool usbpdpower prints 'Disconnected' and 'SNK Charger PD' on Vayne without and with USB-C charger, respectively. Verify ectool usbpdpower prints 'Disconnected' and 'SNK Charger Type-C' on Vayne without and with a phone USB-C charger, respectively. Change-Id: I9aca575a4a4240ec1f669c55437decaedf758a77 Reviewed-on: https://chromium-review.googlesource.com/1222092 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1400151 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* charge_ramp: Allow USB-C power to be ramped by hardwareDaisuke Nojiri2018-12-181-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, hardware ramping (= voltage regulation) is automatically disabled for USB-C power supplier (HARGE_SUPPLIER_PD & _TYPEC). This patch allows USB-C suppliers to get voltage regulation. It prevents the input voltage of weak suppliers from drooping. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/80163913,b/120238339 BRANCH=none TEST=Verify Vayne get charged by PD and Type-C adapters. TEST=Verify on Vayne input current limit is set to adapters' limit. Change-Id: Ideecac911822ffca33be1755846febfcb822f734 Reviewed-on: https://chromium-review.googlesource.com/1377564 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit db32f244a7dbae24ae83633cad1d5b4deb92c5e0) Reviewed-on: https://chromium-review.googlesource.com/c/1382894 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* USB-PD: Debounce when trying try.srcDaisuke Nojiri2018-12-181-14/+13
| | | | | | | | | | | | | | | | | | | | | | | Currently, if try.src is enabled, the TCPM doesn't debounce for SNK connection. This patch makes the TCPM wait for tPDDebounce when detecting SNK connection after switching from SNK to SRC for try.src. BUG=b:115464001 BRANCH=none TEST=On Sona, verify picture is shown on HP s240.via USB-C TEST=On Sona, verify picture is shown on HP s240 via Hoho. Change-Id: I4f91bfca4f829f051d1c33f88f3664fad9b83e9f Reviewed-on: https://chromium-review.googlesource.com/1297035 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit 8641a3876fb60bec2faf548c7baa53a562943c56) Reviewed-on: https://chromium-review.googlesource.com/c/1297033 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* keyboard: restore KBD_KSO2 after keyboard factory scan testingDevin Lu2018-12-183-3/+12
| | | | | | | | | | | | | | | | | | | | | This patch fix the keyboard malfucntion with KBD_KSO2 line after executed "ectool kbfactorytest". BUG=b/119035669 BRANCH=octopus TEST=make sure keyboard works after executed "ectool kbfactorytest" on meep. Change-Id: I33c22e59a01884ff6c961161e189583a6c3673a3 Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/1373389 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit 2577c1cddd38b7c0c04cb57f6941b10c205b99e7) Reviewed-on: https://chromium-review.googlesource.com/c/1382891 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Increase VR5 output by 3%Daisuke Nojiri2018-12-121-3/+3
| | | | | | | | | | | | | | | | | | | | | Currently, VR5 output is boosted by 2%. With 3A current on VBUS, the IR drop between the PMIC and the sink device can cause VBUS to be below 4.75V, which is the minimum VBUS port voltage regulated by the USB-C spec. This patch increase VR5 output voltage by 3%. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/80163913,b/120238339 BRANCH=none TEST=Verified by ODM on Syndra. Change-Id: I30b786440610148b710f74cfcd3824f32c8ad4e5 Reviewed-on: https://chromium-review.googlesource.com/c/1220014 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Fix build error due to CL:1363818Daisuke Nojiri2018-12-111-1/+1
| | | | | | | | | | | | | | Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:117827249 BRANCH=none TEST=Run emerge-nami chromeos-ec Change-Id: Ibfe41bbfdef4c38e0b611dc5b38f1a6c7aa7eafe Reviewed-on: https://chromium-review.googlesource.com/c/1372030 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Re-enable search key scanning on SyndraDaisuke Nojiri2018-12-071-3/+8
| | | | | | | | | | | | | | | | | | | | | Search key coordinate was moved to col=0,row=3 on Ekko and Bard and CL 1343640 was merged to adjust the scan mask. Syndra doesn't have this move. So, this patch will make the search key scanned like before while keeping the previous change applied to only Ekko & Bard. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:119798830 BRANCH=none TEST=Verify search key works on Syndra, Sona, Ekko, and Bard. Change-Id: Ia672383ca8df8e2e212c8c9deb0410c968e357e4 Reviewed-on: https://chromium-review.googlesource.com/c/1366300 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Add fan min/start/max definition for SyndraDaisuke Nojiri2018-12-071-1/+10
| | | | | | | | | | | | | | | | This patch adds fan RPM definitions for Syndra. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:120113410 BRANCH=none TEST=buildall Change-Id: I3bbdc98713c2dd8b0ed824a8576ffb2f597240ae Reviewed-on: https://chromium-review.googlesource.com/c/1363672 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Support UK2 keyboardDaisuke Nojiri2018-12-062-0/+10
| | | | | | | | | | | | | | | | | | | | | This patch swaps the forwardslash-pipe key (scancode=0x56) with the right control key (scancode=0xe014) if UK2 bit in SKU ID is enabled. evtest produces: type 1 (EV_KEY), code 86 (KEY_102ND), value 1 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:117827249 BRANCH=none TEST=Verify forwardslash key produces keycode=0x1d on Syndra with UK2. TEST=Verify '\' and '|' are printed on OS (with input method = UK). Change-Id: Ibbaeccd12cfc09d913ecfe1172218297c3d7341a Reviewed-on: https://chromium-review.googlesource.com/c/1363818 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* util: Add macro to swap two variablesDaisuke Nojiri2018-12-062-0/+34
| | | | | | | | | | | | | | | | | | | This patch adds swap(a,b), which swaps the values in two variables. It requires c99 for typeof. Swapping composites (e.g. a+b, x++) doesn't make sense. So, <a> and <b> can only be a variable (x) or a pointer reference (*x) without an operator. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: Id656e173d372dfff759d9aee9314a008a6d91786 Reviewed-on: https://chromium-review.googlesource.com/c/1366304 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Define charge LED behavior for SyndraDaisuke Nojiri2018-12-053-2/+30
| | | | | | | | | | | | | | | | | | | | | | | Syndra does not have a power LED. We'll use the charge LED to show system status using the following pattern: Charge: Amber on Full: White on Discharge in s0: White on Discharge in s3: White on 1 sec off 1 sec Discharge in s5: off Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:120105950 BRANCH=none TEST=Set MODEL_ID=1 and verify charge LED behaves as expected on Sona. Change-Id: I42228a7ad2f736dd98520d4652981138d8c0e44e Reviewed-on: https://chromium-review.googlesource.com/c/1363671 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* CBI: Add MODEL_ID fieldDaisuke Nojiri2018-11-305-13/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MODEL_ID is an optional field containing a numeric value identifying models. Model IDs are unique within each OEM and <OEM_ID, MODEL_ID> should form a unique ID within the family. $ cbi-util create --file ~/cbi_image --board_version 0 --oem_id 6 --sku_id 255 --dram_part_num "012345679abcdef" --model_id 127 --size 256 $ hexdump -C /tmp/cbi.bin 0000 43 42 49 fa 00 00 26 00 00 01 00 01 01 06 02 01 |CBI...&.........| 0010 ff 05 01 7f 03 10 30 31 32 33 34 35 36 37 39 61 |......012345679a| 0020 62 63 64 65 66 00 ff ff ff ff ff ff ff ff ff ff |bcdef...........| $ cbi-util show --file /tmp/cbi.bin CBI image: /tmp/cbi.bin TOTAL_SIZE: 38 Data Field: name: value (hex, tag, size) BOARD_VERSION: 0 (0x0, 0, 1) OEM_ID: 6 (0x6, 1, 1) SKU_ID: 255 (0xff, 2, 1) MODEL_ID: 127 (0x7f, 5, 1) DRAM_PART_NUM: 012345679abcdef (3, 16) Data validated successfully localhost # ectool cbi set 5 127 1 localhost # ectool cbi get 5 As integer: 127 (0x7f) As binary: 7f > cbi [1289.860454 CBI Reading board info] CBI_VERSION: 0x0000 TOTAL_SIZE: 22 BOARD_VERSION: 513 (0x201) OEM_ID: 3 (0x3) MODEL_ID: 127 (0x7f) SKU_ID: 14951 (0x3a67) 43 42 49 b0 00 00 16 00 00 02 01 02 01 01 03 02 02 67 3a 05 01 7f ff ff ff ff ff ff ff ff ff ff Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:119522898,b:120105950 BRANCH=none TEST=See above. Change-Id: Ifd6f3087f5422bcf4c36d3d981b262653d0c89dc Reviewed-on: https://chromium-review.googlesource.com/1341099 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1355377 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* CBI: Clarify value types in help messagesDaisuke Nojiri2018-11-303-24/+25
| | | | | | | | | | | | | | | | | | | | This patch make cbi-util and ectool show OEM_NAME and DRAM_PART_NUM take a string parameter. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:118798180 BRANCH=none TEST=buildall Change-Id: I7b4e126f02f9488ce6059c090a5f3ec665b39406 Reviewed-on: https://chromium-review.googlesource.com/1323852 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1355376 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* Add OEM name support to CBIWisley Chen2018-11-303-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow to set/get the OEM name in CBI. $ cbi-util create --file ./cbi_image.bin --board_version 1 --oem_id 6 --sku_id 255 --dram_part_num "0123456789abcdef" --oem_name "ABC" --size 256 CBI image is created successfully $hexdump -C cbi_image.bin 00000000 43 42 49 ed 00 00 2a 00 00 01 01 01 01 06 02 01 |CBI...*.........| 00000010 ff 03 11 30 31 32 33 34 35 36 37 38 39 61 62 63 |...0123456789abc| 00000020 64 65 66 00 04 04 41 42 43 00 ff ff ff ff ff ff |def...ABC.......| 00000030 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00000100 $ ./build/meep/util/cbi-util show --file ./cbi_image.bin CBI image: ./cbi_image.bin TOTAL_SIZE: 42 Data Field: name: value (hex, tag, size) BOARD_VERSION: 1 (0x1, 0, 1) OEM_ID: 6 (0x6, 1, 1) SKU_ID: 255 (0xff, 2, 1) DRAM_PART_NUM: 0123456789abcdef (3, 17) OEM_NAME: ABC (4, 4) Data validated successfully localhost /usr/local # ./ectool cbi set 0 1 1 2 localhost /usr/local # ./ectool cbi set 1 6 1 1 localhost /usr/local # ./ectool cbi set 2 255 1 1 localhost /usr/local # ./ectool cbi set 3 K4F6E304HB-MGCJ 0 0 localhost /usr/local # ./ectool cbi set 4 ABC 0 0 localhost /usr/local # ./ectool cbi get 0 As integer: 1 (0x1) As binary: 01 localhost /usr/local # ./ectool cbi get 1 As integer: 6 (0x6) As binary: 06 localhost /usr/local # ./ectool cbi get 2 As integer: 255 (0xff) As binary: ff localhost /usr/local # ./ectool cbi get 3 K4F6E304HB-MGCJ localhost /usr/local # ./ectool cbi get 4 ABC BRANCH=none BUG=b:118798180 TEST=executed command as above. Signed-off-by: Wisley Chen <wisley.chen@quantatw.com> Change-Id: Ie933900ffd6c1317136c88a72ab8d5afc3976cc0 Reviewed-on: https://chromium-review.googlesource.com/1319394 Commit-Ready: Chen Wisley <wisley.chen@quantatw.com> Tested-by: Chen Wisley <wisley.chen@quantatw.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1355375 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Add DRAM part number support to CBIAaron Durbin2018-11-303-17/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow one to encode the DRAM part number in CBI. Both cbi-util and ectool are updated. $ cbi-util create --file ~/cbi_image --board_version 0 --oem_id 6 --sku_id 255 --dram_part_num "012345679abcdef" --size 256 CBI image is created successfully $ hexdump -C ~/cbi_image 00000000 43 42 49 47 00 00 23 00 00 01 00 01 01 06 02 01 |CBIG..#.........| 00000010 ff 03 10 30 31 32 33 34 35 36 37 39 61 62 63 64 |...012345679abcd| 00000020 65 66 00 ff ff ff ff ff ff ff ff ff ff ff ff ff |ef..............| 00000030 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00000100 $ cbi-util show --file ~/cbi_image CBI image: /home/adurbin/cbi_image TOTAL_SIZE: 35 Data Field: name: value (hex, tag, size) BOARD_VERSION: 0 (0x0, 0, 1) OEM_ID: 6 (0x6, 1, 1) SKU_ID: 255 (0xff, 2, 1) DRAM_PART_NUM: 012345679abcdef (3, 16) Data validated successfully localhost /tmp # ./ectool cbi set 0 0 1 2 localhost /tmp # ./ectool cbi set 1 6 1 1 localhost /tmp # ./ectool cbi set 2 255 1 1 localhost /tmp # ./ectool cbi set 3 H9HCNNNBPUMLHR 0 0 localhost /tmp # ./ectool cbi get 0 As integer: 0 (0x0) As binary: 00 localhost /tmp # ./ectool cbi get 1 As integer: 6 (0x6) As binary: 06 localhost /tmp # ./ectool cbi get 2 As integer: 255 (0xff) As binary: ff localhost /tmp # ./ectool cbi get 3 H9HCNNNBPUMLHR BUG=b:112203105 BRANCH=None TEST=Commands executed above. Change-Id: I2d519ad16a158db4e624d3a03912434d0e8fdd73 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1165622 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1355374 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* util/cbi-util: Check pointer before using itPatrick Georgi2018-11-301-1/+3
| | | | | | | | | | | | | Change-Id: If11de8883b001f16d7e8f859a416fbdc5ea0391a Signed-off-by: Patrick Georgi <pgeorgi@google.com> Found-by: Coverity Scan #187038 Reviewed-on: https://chromium-review.googlesource.com/1151121 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1355373 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* util/cbi-util: Fix resource leaksPatrick Georgi2018-11-301-0/+3
| | | | | | | | | | | | | Change-Id: I1bac7756df713be66011c75df7e04b0ed342b96d Signed-off-by: Patrick Georgi <pgeorgi@google.com> Found-by: Coverity Scan #187040, #187042 Reviewed-on: https://chromium-review.googlesource.com/1151120 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1355372 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Add battery AP18F4M for Bard and EkkoDavid Huang2018-11-282-8/+51
| | | | | | | | | | | | | | | | Add AP18F4M battery config and discharge fet status for Bard and Ekko. Battery type is encoded in SKU_ID[24:31]. Akali/Akali360 have been shipped with SKU_ID[24:31] equal to zero. BRANCH=nami BUG=b:112564628, b:119522898 TEST=Make sure battery cut-off by console command "cutoff" and use "chgstate" to check battery present is YES after resume from cut-off. Change-Id: I55df5d212b834649f1c05425541b808fb4900e87 Signed-off-by: David Huang <David.Huang@quantatw.com> Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1319731
* Nami: modify actual_key_mask to enable the "Search" key for the keyboardSue Chen2018-11-271-1/+3
| | | | | | | | | | | | | | | | with keypad BUG=b:119798830 BRANCH=firmware-nami-10775.B TEST=Use ksstate console to check it can show the right point for the "Search" key after pressing the key. Change-Id: I068b629d962a3f9ebf70ef9785610bc9fc424696 Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/1343640 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Add new LED behavior for factory modeSue Chen2018-11-261-4/+35
| | | | | | | | | | | | | | | The factory mode is indicated by blue on for 2sec & amber on for 2sec. BUG=none BRANCH=firmware-nami-10775.B TEST=Check charge led is blue on 2sec Amber on 2sec when factory testing Change-Id: Ifc3786151ccef29e709587f8f5b3d3306a6b344f Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/1337252 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Reland "Battery: USE Host full capacity to compute display percentage"Daisuke Nojiri2018-11-163-17/+27
| | | | | | | | | | | | | | | | | | | | | | | The full capacity known by the host may slightly differ from the full capacity known by the EC because we notify the host of the new capacity only if the difference is larger than 5 mAh. This patch makes the EC use the host's full capacity instead of the local full capacity to compute the display percentage. (Relanding CL:1330101 patchset 6) BRANCH=none TEST=Verify display percentages printed by EC and power_supply_info move up synchronously on charge and the LED and the taskbar icon turn to full at the same time. TEST=buildall Change-Id: If9e0c9989e19bb9085866a86b47d1c200fc70b80 Reviewed-on: https://chromium-review.googlesource.com/c/1340542 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* Revert "Battery: Use host full capacity to compute display percentage"Daisuke Nojiri2018-11-161-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 98da1db95df8ebd31e77c7f61e1f3123930bb7f1. Reason for revert: Replacing it with a different version of the same patch. Patchset6 of CL:1330101 Original change's description: > Battery: Use host full capacity to compute display percentage > > The full capacity known by the host may slightly differ from the full > capacity known by the EC because we notify the host of the new > capacity only if the difference is larger than 5 mAh. > > This patch makes EC use the host full capacity instead of the local > full capacity to compute the display percentage. > > Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> > > BUG=b:109954565,b:80270446 > BRANCH=none > TEST=Verify display percentages printed by EC and power_supply_info > move up synchronously on charge and the LED and the taskbar icon > turn to full at the same time. > > Change-Id: Ie695a9937a22fc7a769b82448f4600d4491935b3 > Reviewed-on: https://chromium-review.googlesource.com/c/1330103 > Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> > Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> > Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Bug: b:109954565, b:80270446 Change-Id: I84ac232d1bfc3195584f5580069b484402a9cbf8 Reviewed-on: https://chromium-review.googlesource.com/c/1340541 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Supply power up to 3A + 1.5ADaisuke Nojiri2018-11-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | This change allows Nami to supply 3A on one port and 1.5A to the other without changing the max current of the currently active port. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:115291657 BRANCH=none TEST=Charge Pixel phone on one port and a USB fan on the other. Verify the current provided to the phone does not drop. Change-Id: I38208feedc616e363c9095f273ea926ea8ebbb12 Reviewed-on: https://chromium-review.googlesource.com/1322070 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit a2c7fd10c148a913828f63fdbc0599f63804b22e) Reviewed-on: https://chromium-review.googlesource.com/c/1340540 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* USB-PD: Supply power up to 3A + 1.5ADaisuke Nojiri2018-11-162-22/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, USB PD ports supply 3A only if there is no other active supplier. We enforce this rule even if the port is actively supplying power. That is, we drop the max current of an active port to 1.5A if a sink device is plugged to another port. This change makes USB PD ports supply 3A if the other ports are not supplying 3A. (P0, P1) and '*' indicates a sink device is plugged. Unplug both: (3A, 3A) Plug P0: (*3A, 1.5A) Plug P1: (*3A, *1.5A) Unplug P0: (1.5A, *3A) Unplug P1: (3A, 3A) Plug P1: (1.5A, *3A) Plug P0: (*1.5A, *3A) Unplug P0: (1.5A, *3A) Unplug P1: (3A, 3A) Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:115291657 BRANCH=none TEST=Performed as shown above and verify current of active port is not affected by the other port. Change-Id: I08fb04da7e0177d5e71f823fb1e47e6945ae12fc Reviewed-on: https://chromium-review.googlesource.com/1322069 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Raymond Chou <raymond_chou@compal.corp-partner.google.com> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit 88302ce7f21f16f0902fe5da033dd3d3e4091458) Reviewed-on: https://chromium-review.googlesource.com/c/1340539 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Battery: Use host full capacity to compute display percentageDaisuke Nojiri2018-11-091-5/+10
| | | | | | | | | | | | | | | | | | | | | | | The full capacity known by the host may slightly differ from the full capacity known by the EC because we notify the host of the new capacity only if the difference is larger than 5 mAh. This patch makes EC use the host full capacity instead of the local full capacity to compute the display percentage. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify display percentages printed by EC and power_supply_info move up synchronously on charge and the LED and the taskbar icon turn to full at the same time. Change-Id: Ie695a9937a22fc7a769b82448f4600d4491935b3 Reviewed-on: https://chromium-review.googlesource.com/c/1330103 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Revert "Battery: Set full_capacity charge host event threshold to zero"Daisuke Nojiri2018-11-093-16/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 84e862116d718ee2a9a662def4eb4ec160748743. Reason for revert: Being replaced by CL:1330101. Original change's description: > Battery: Set full_capacity charge host event threshold to zero > > Currently, when a battery updates the full_capacity, a host is notified > only if it goes up or down more than 5 mAh. This workaround is not > needed for good batteries. > > This change sets the threshold to zero except for Samus. > > Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> > > BUG=b:109954565,b:80270446 > BRANCH=none > TEST=Verify display percentages printed by EC and power_supply_info > move up synchronously on charge and the LED and the taskbar icon > turn to full at the same time. > > Change-Id: Ice0de712515e25929604376c8fe487b2be14b22c > Reviewed-on: https://chromium-review.googlesource.com/c/1327126 > Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> > Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> > Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Bug: b:109954565, b:80270446 Change-Id: I6538c7d2622be37809d83ca8bec8689f87a152f2 Reviewed-on: https://chromium-review.googlesource.com/c/1330163 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Battery: Make battery command print display percentageDaisuke Nojiri2018-11-081-1/+8
| | | | | | | | | | | | | | | | | | This patch make battery console command print display percentage and compensated full capacity. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify display percentage and compensated full capacity are printed on Sona. Change-Id: Idc8ee063249fd0937209c8cb32aee59ee3598258 Reviewed-on: https://chromium-review.googlesource.com/c/1327127 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Battery: Set full_capacity charge host event threshold to zeroDaisuke Nojiri2018-11-083-5/+16
| | | | | | | | | | | | | | | | | | | | | | Currently, when a battery updates the full_capacity, a host is notified only if it goes up or down more than 5 mAh. This workaround is not needed for good batteries. This change sets the threshold to zero except for Samus. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify display percentages printed by EC and power_supply_info move up synchronously on charge and the LED and the taskbar icon turn to full at the same time. Change-Id: Ice0de712515e25929604376c8fe487b2be14b22c Reviewed-on: https://chromium-review.googlesource.com/c/1327126 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Apply full factor to full capacityDaisuke Nojiri2018-11-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | This change applies 'full factor' to the battery full capacity. It makes the rest of the system see consistent charge percentage behavior. More concretely, with this change we can get rid of 'full factor' from Powerd because it sees the current charge equal to the full capacity. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> #CQ-DEPEND=CL:1314048 BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify display percentages printed by EC and power_supply_info move up synchronously on charge and the LED and the taskbar icon turn to full at the same time. Change-Id: Ic16463d457a6c5c2860b97476c78bdafb9021572 Reviewed-on: https://chromium-review.googlesource.com/c/1327125 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Battery: Apply full factor to full capacityDaisuke Nojiri2018-11-082-11/+14
| | | | | | | | | | | | | | | | | | | | This change introduces CONFIG_BATT_HOST_FULL_FACTOR. If it's 100, meaning no compensation, we multiply full capacity by CONFIG_BATT_FULL_FACTOR. This makes the rest of the system see consistent charge percentage behavior. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify display percentages printed by EC and power_supply_info move up synchronously on charge and turns to full at the same time. Change-Id: Ifb27c802b0cf04195ac5b426c13f9476189feb75 Reviewed-on: https://chromium-review.googlesource.com/c/1327124 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* Nami: Use display battery percentage to control LEDDaisuke Nojiri2018-11-081-20/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, remaining capacity read from a battery is converted first by ACPI and then by powerd. Without knowing the conversion, EC is not able to control LEDs synchronously to the number on the display. This patch makes Nami EC use display percentages to control LEDs. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify charge LED changes to white (full) on Sona synchronously to the display percentage. TEST=Verify charge LED changes to blinking white (low) on Sona within 30 seconds synchronously to the display percentage. Change-Id: I5d451a24bed3a136dee4d7ac27a57caf75fcb856 Reviewed-on: https://chromium-review.googlesource.com/1309035 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit 600a960bbeb8269a47848169b59b1f6a219527f7) Reviewed-on: https://chromium-review.googlesource.com/c/1327122 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* chgstv2: Notify on display percentage changeDaisuke Nojiri2018-11-082-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | This patch makes the charger task v2 notify HOOK_BATTERY_SOC_CHANGE handlers when the display charge percentage changes. This allows EC to update LEDs synchronously to the number on the display. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify charge LED changes to white (full) on Sona synchronously to the display percentage. TEST=Verify charge LED changes to blinking white (low) on Sona within 30 seconds synchronously to the display percentage. Change-Id: Ib2c587ad3307fe62b268a25a93344c88c6c137f3 Reviewed-on: https://chromium-review.googlesource.com/1309034 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit ba92cadcf87075d80e065bfe606286d1885817b1) Reviewed-on: https://chromium-review.googlesource.com/c/1327121 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* Battery: Get display charge percentageDaisuke Nojiri2018-11-083-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | This patch converts the actual battery charge to the display percentage using the same conversion used by Powerd. EC can use this number to control LEDs synchronously to the value on the display. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify charge LED changes to white (full) on Sona synchronously to the display percentage. TEST=Verify charge LED changes to blinking white (low) on Sona within 30 seconds synchronously to the display percentage. Change-Id: I2041cb768dee27b8dba94a32db0eb62dfa14c73b Reviewed-on: https://chromium-review.googlesource.com/1309033 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit 776eadc1b4b1a92688c441cbebfacf1eea6471fc) Reviewed-on: https://chromium-review.googlesource.com/c/1327101 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>