summaryrefslogtreecommitdiff
path: root/driver
Commit message (Collapse)AuthorAgeFilesLines
* ec: add driver/touchpad_st.cWei-Han Chen2018-03-263-0/+720
| | | | | | | | | | | | | | | | | | Initial commit for ST touchpad. This CL will support X/Y mode function. BRANCH=none BUG=b:70482333 TEST=make BOARD=whiskers TEST=manually test touchpad function on whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I1669286ca764fbbd4a691171193415dd4999673f Reviewed-on: https://chromium-review.googlesource.com/958894 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* sensor: bmi160/bma2x2: Fix the timeout value of compensation.Marco Chen2018-03-262-2/+2
| | | | | | | | | | | | | | | | | | | CL:957872 introduced "get_time().val + 400" as the deadline to perform compensation and the comment in bma2x2.c mentioned the deadline should be 400ms. But the unit of val in timestamp_t is microsecond not milisecond so only 400us is defined not 400ms. BRANCH=none BUG=b:76234078 BUG=b:76202592 TEST=test manually on the dut by performing calibrate. Change-Id: I7a834ef6dcb0772569d2c8d6c507803deb5d2fc1 Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/979512 Commit-Ready: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* battery/max17055: Report the raw measured currentPhilip Chen2018-03-231-1/+1
| | | | | | | | | | | | | | BUG=b:74321682 BRANCH=scarlet TEST=battery command shows current change instantaneously when AC charger is plugged/unplugged Change-Id: Ic47efbdfc861355325ee2c69be09fbcfa1394654 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/977022 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* tcpc: rename CONFIG_USB_PD_TCPM_ANX74XX to CONFIG_USB_PD_TCPM_ANX3429Jett Rink2018-03-232-2/+6
| | | | | | | | | | | | | | | | | | | | | Since all of the uses of CONFIG_USB_PD_TCPM_ANX74XX are actually for ANX3429, rename the option especially since the ANX7447 driver will not reuse the ANX74XX driver which is being introduced in CL:956790. Also adding the CONFIG_USB_PD_TCPM_ANX740X and CONFIG_USB_PD_TCPM_ANX741X options to advertise which versions of the ANX chip the anx74xx.c driver applies to. BRANCH=none BUG=chromium:824208 TEST=build all Change-Id: Ib47f4661466e54ff2a0c52d517eb318d3bfd25a2 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/973558 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* usb_mux: Fix incorrect revision check at init for ps874xDivya Sasidharan2018-03-222-9/+17
| | | | | | | | | | | | | | | | | | | | | | This patch fixes revision check for ps8xxx usb mux and thereby removing print "Error initializing mux port(x)" at bootup. This is just a cosmetic change and should not affect any functionality. BUG=none BRANCH=glkrvp TEST=On glkrvp: Boot up the system to verify the error message setting mux is gone at init. Change-Id: I0926077d50e818bd93aaa4214106b2f8067d9710 Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com> Reviewed-on: https://chromium-review.googlesource.com/846291 Commit-Ready: Divya S Sasidharan <divya.s.sasidharan@intel.com> Tested-by: Divya S Sasidharan <divya.s.sasidharan@intel.com> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* battery/max17055: Implement battery_status()Philip Chen2018-03-212-1/+26
| | | | | | | | | | | | | | BUG=b:74841068 BRANCH=scarlet TEST='/sys/class/power_supply/sbs-9-000b/status' shows discharging/charging/full status correctly Change-Id: I4216ba2d95ac82a9f600d8685d993cb5b37206d8 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/969747 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ppc: Add driver for NX20P3483Scott Collyer2018-03-204-0/+441
| | | | | | | | | | | | | | | | | | | | | | | | | | The NX20P3483 is a USB PD and Type C high voltage sink/source combo switch. This CL adds support for this PPC variant. Unlike the TI SN5S330, the NX20P3483 does not support VCONN and does not need to be informed of CC polarity by the TCPM. To account for these differences, 2 new PPC config options are added and the driver for the TI SN5S330 was modified to include these new options. The SNK/SRC switch mode for the NX20P3483 is controlled by 2 GPIO signals which may be connected the EC or directly to the TCPC. To handle both cases, the ppc_chips structure was modified with a flags, snk_gpio, and src_gpio elements. BUG=b:74206647 BRANCH=none TEST=make -j buildall and verified there are no build errors. Change-Id: Ic4415ab7571b80e7661ea673434eaf4cf1f1fd2d Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/966926 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* driver: lsm6dsm: fix unitsGwendal Grignou2018-03-192-23/+9
| | | | | | | | | | | | | | | Units must be reported in according to the range. 2g means 1<<15 should be returned when accel is 2g. Actually accelerometer report units in mg. BUG=b:73546254 BRANCH=master TEST=Check with accelinfo with 2g gain Z ~= 1<<14. Change-Id: I218210ca8305ecbe76a681b535f3d75f3a6bea52 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/924408 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: lis2dh: fix gain unitsGwendal Grignou2018-03-192-36/+7
| | | | | | | | | | | | | | Accelerometer reports accelerating in mg. Fix gain to that full range (2g, 4g or 8g) returns 2<<15. BUG=b:73546254 BRANCH=master TEST=compile Change-Id: I2873a641985fa800709a2d30b031c2b6e3fcb39e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/924407 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: accel_lis2dh: Fix interfaceGwendal Grignou2018-03-192-2/+6
| | | | | | | | | | | | | Add support in ectool, expose min/max ODR. BUG=b:73546254 BRANCH=master TEST=compile Change-Id: Ib09c06e17d7d73aaab91680672de4d5267299c7f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/924405 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: lsm6dsm/lsm6dsl/lis2dh: Use STM MEMs common functionsGwendal Grignou2018-03-196-227/+150
| | | | | | | | | | | | | | | | | | | LSM6DSM now use STM MEMs common functions already used by LIS2DH12 device. Added st_raw_read_n_noinc function to read i2c data not using auto increment protocol. BUG=b:73546254 BRANCH=master TEST=Tested on discovery BOARD with LSM6DSM sensor connected on I2C master bus interface of target board. Using motion sense console commands is possible to enable, set data rate, set full scale and show data from sensor (acc and gyro). Commons function works properly for LSM6DSM. Change-Id: I7a987306135a85abcfa9c1d3ba596fb70598fadc Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/465376
* driver: kionix: Add software reset flow for KX022Yidi Lin2018-03-192-49/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Kionix suggests that it is recommended to issue the Software Reset command after the device was powered. This is effective against dynamic or non-linear behavior of a power supply or unexpected noise above normal on the power rail during a power up. BRANCH=eve BUG=b:62607555 TEST=kx022: 1. press power button 10 second to power off. 2. power on the DUT 3. refresh + power button to cold reboot the DUT 4. Check the g-sensor by 'ectool motionsense' kxcj9: eve: sensor kxcj9 found. Signed-off-by: Yidi Lin <yidi.lin@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/536723 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> (cherry picked from commit 5a52614b8c87ab1de84c461b7bbd0b4a14dc7fdb) Conflict in init routine in accel_kionix.c. By moving WHOAMI after reset, we expect the test to work the first time.) Change-Id: I362f2af59253519aa35b72cfb6b666c49e425777 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/753969
* Revert "driver: kionix: Add checking whoami value at initialization."Gwendal Grignou2018-03-191-1/+1
| | | | | | | | | | | | | | | This reverts commit 1d8fcd4fabfed67d8304b3c5ad418cf6f5ae1878. It looks like KXCJ9 may not return proper WHOAMI after powerup but before reset. BUG=b:67865186 BRANCH=eve TEST=compile Change-Id: Iceaaf3b2a45d920e08db587e1308cec0379e68cf Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/753967 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: bma2x2: Add perform_calibGwendal Grignou2018-03-163-45/+89
| | | | | | | | | | | | | | | | | | Add fast compensation automatic calibration, like bmi160. Use timestamp_expired for timeout measurement for both perform_calib functions. Remove driver offset field, remove private bma2x2 structure. BUG=b:73205042 BRANCH=master TEST=echo 1 > calibrate perform calibration. Reading in_accel_*_calibbias is within range. Check on Lami for both bma2x2 and bmi160. Change-Id: I3472865287fa4769a05e6f872b92d7c3f933cb4e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/957872 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* driver: sensor: Remove set_resolution when NOOPGwendal Grignou2018-03-158-70/+0
| | | | | | | | | | | | | | set_resolution is only used for few sensors and is not exposed to the AP. Remove definition when sensors have a fixed resolution. BUG=none BRANCH=master TEST=compile, kevin has enough space for perform_calib. Change-Id: I8482387e135356467edaee44da3a0e47cf1db524 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/961222 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: kionix: Use base accelgyro structureGwendal Grignou2018-03-152-11/+11
| | | | | | | | | | | | | | Unify get_range/get_datarate by using accelgyro_saved_data_t structure. BUG=none BRANCH=none TEST=compile Change-Id: I0bfa2f06c5dd2021a5af9e6499c97e65988167ce Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/961221 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: bma2x2: Remove tables for range/frequencyGwendal Grignou2018-03-152-82/+37
| | | | | | | | | | | | | | | | To save space, instead of using tables, use macros to convert range/frequencies into register values. BUG=b:73205042 BRANCH=none TEST=Check we save space on Kevin. (184 bytes looking at __image_size in kevin.RO.map). Check on nami that range/bandwidth are set properly. Change-Id: I193768be1f2e7325b986e8ccff25a7809bfb4096 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/959388 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* battery/max17055: Fix the unit of cycle countPhilip Chen2018-03-141-1/+9
| | | | | | | | | | | | | | | | | | The cycle counts we get from battery_cycle_count() is in the unit of 1%. But we should convert it to absolute count to match the behavior of a smart battery. BUG=b:74576000 BRANCH=scarlet TEST='ectool battery' shows reasonable cycle counts Change-Id: I9d351f8766c90e0addb72a088917ddadfa6c840a Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/961303 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: OPT3001: Re-order application of scale.Aseda Aboagye2018-03-141-3/+6
| | | | | | | | | | | | | | | | | This commit simply reorders the application of scale in order to preserve the sensor precision. BUG=b:72985601 BRANCH=stabilize-meowth-10444.B TEST=Flash meowth; Set scale to 1000; Verify that more significant digits are present compared to before. Change-Id: Ibf46e574fccdde50ceb5f8174f9b4a29e60bfbfe Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/955967 Commit-Ready: Gwendal Grignou <gwendal@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* sensors: Add driver for SYNCAlexandru M Stan2018-03-143-0/+139
| | | | | | | | | | | | | | | | | Useful for recording the exact time a gpio interrupt happened in the context of sensors. Adding it for camera vsync purposes. BUG=b:67743747 TEST=With next patch see it work on scarlet. BRANCH=master Change-Id: Ic8e8fb444e08200e5d8daded8b4a5920b13431ac Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/850580 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* motion: Lower jitter of Sensor->EC timestampAlexandru M Stan2018-03-143-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead getting the time for each sample in the task code, we should be getting it as soon as the sensor reported it added it to its fifo (so sensor just finished integration). Because of that each sensor should provide the time when it provides a sample, ideally from an accurate spot like an interrupt. Deprecate motion_sense_fifo_add_unit (without a timestamp) in favour of motion_sense_fifo_add_data (which adds the timestamps). Update all relevant sensors to use the new api. Note: for now I focused on the BMI160, where I actually made it get the time in the interrupt. The other sensors were made to use the new api, but still don't record the time in the right place (though it's not any worse than before). BUG=b:67743747 TEST=In the kernel, fifo_info->info.timestamp still has sane values. TEST=CTS should still pass BRANCH=master Change-Id: I9829343f8702e00cc19f9c88134fa1f258c9e1e9 Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/807331 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* driver: bma2x2: indent register definitionGwendal Grignou2018-03-122-95/+98
| | | | | | | | | | | BUG=none BRANCH=none TEST=compile Change-Id: I9507cbe760f886acaa4c6b432cfd8482faeb4618 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/959387 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* charger/rt946x: Enable charge current terminationPhilip Chen2018-03-122-1/+7
| | | | | | | | | | | | | | | BUG=b:74373538 BRANCH=scarlet TEST=confirm charge current drops to 0mA right after it hits 400mA, when battery is nearly fully charged Change-Id: Icd4a7886bf68f3bd4ed91d2b8e705cb62f6e4fb8 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/958295 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: David Schneider <dnschneid@chromium.org>
* charger/rt946x: Limit ADC timeout to 50msPhilip Chen2018-03-091-13/+17
| | | | | | | | | | | | | | | | | | | | | In practice, ADC conversion rarely takes more than 35ms. However, according to the datasheet, ADC conversion may take up to 200ms. But we can't wait for that long, otherwise host command would time out. So here we set ADC timeout as 50ms. If ADC times out, we just return the last read vbus_mv. BUG=b:70641844, chromium:780364 BRANCH=scarlet TEST=test 'ectool usbpdpower' for 50k cycles w/o seeing host command timeout Change-Id: I09c3abf729e96b113f7a0f64a67cd35906da9e3e Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/956900 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org>
* bc12: add support for active low/high on all gpio signalsJett Rink2018-03-092-21/+69
| | | | | | | | | | | | | | yorp inverts both bc12 signals and the bc12 driver needs to handle the inverted logic BRANCH=none BUG=b:74127309 TEST=none Change-Id: I6848375fc652251aecb553c3f53d62a5f775bec4 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/956321 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* motion: remove load_fifoGwendal Grignou2018-03-094-173/+180
| | | | | | | | | | | | | | | | | | | | | To prevent invalid timestamping, call load_fifo only when we get a FIFO interrupt. In consequence, remove load_fifo entry point and only process fifo inside the IRQ. Add helper function to know when we are in forced mode (the EC needs to periodically read sensor data or interrupt driven). BUG=b:73557414 BRANCH=master TEST=compile Change-Id: I959e476f3f7215be95424c07223f7421e8b13da1 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/938146 Commit-Ready: Alexandru M Stan <amstan@chromium.org> Tested-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org>
* sensor: bmi160: Don't batch data on the sensorAlexandru M Stan2018-03-091-3/+2
| | | | | | | | | | | | | | | | | | | Set the sensor side fifo watermark to interrupt the EC as soon as there's any data in there, that way we get more frequent accelerometer interrupts (which is handy when you want to mark down the time of each sample accuratelly). BUG=b:67743747 TEST=Sensor should still be working normally, the ec will probably start recieving sensor interrupts (before this was probably not the case). BRANCH=master Change-Id: I726550e68447a74bbfed88b703d2f68b6967ac93 Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/956626 Commit-Ready: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* isl923x: Round up requested OTG currentNicolas Boichat2018-03-091-1/+2
| | | | | | | | | | | | | | | | | | | | Without this patch, requesting 100mA or output current would be rounded down to zero. This would also cause other issues when doing base/lid and lid/base power transfers on lux/wand, as the input current has a much finer grain control, which could lead the input charger to brown out the output charger. BRANCH=none BUG=b:67920792 TEST=Flash lux/wand, lux can provide as little as 100mA of current successfully. Change-Id: Ibf170a6ee3c2dfbdbbc03948c3b0e6ab878eee47 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/956660 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* tcpm/fusb302: Update VBUS supplier when VBUS level changesPhilip Chen2018-03-081-4/+22
| | | | | | | | | | | | | | | | | To enable USB charging on boards where fusb302 takes care of VBUS detection BUG=b:65446459 BRANCH=none TEST=on Scarlet rev3, verify VBUS supplier is updated based on whether VBUS is present - plug/unplug USB2 charger, boot with USB2 charger plugged. Change-Id: I50177d40b0eb0490634ad2f103306e0079633fbe Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/905401 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* Introduce CONFIG_USB_PD_5V_CHARGER_CTRLPhilip Chen2018-03-051-0/+10
| | | | | | | | | | | | | | | | Add a new config for the boards using charger (e.g. rt946x) to report if VBUS source is enabled instead of using GPIO. BUG=b:65446459 BRANCH=none TEST=Charge Scarlet rev3 with SDP and DCP. Change-Id: Id0a07945f0f888b6a36c422c596b56c5aa5065c0 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/905400 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* Nami: add keyboard backlight functionElmo_Lan2018-03-023-0/+68
| | | | | | | | | | | | | | | | | | | Base on LM3509 chip. Add file LM3509.C and LM3509.H to control keyboard backlight when S0/LidOpen is turn on, others is turn off. BUG=b:73055990 BRANCH=none TEST=Verify keyboard backlight function in resume and suspend. S0/LidOpen is turn on; S4/S5/G3/LidClose is turn off. Change-Id: Ief9e385f969c9dfc9e8f0d4e47ea7803cee747aa Signed-off-by: Elmo_Lan <elmo_lan@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/881081 Commit-Ready: Raymond Chou <raymond_chou@compal.corp-partner.google.com> Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
* charger/rt946x: Support BC 1.2Philip Chen2018-02-282-3/+102
| | | | | | | | | | | | | BUG=b:65446459 BRANCH=none TEST=Charge Scarlet rev3 with SDP and DCP. Change-Id: I84fb64953c380b96ec852dca2c981331801e4416 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/905399 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Nami: Add remote temperture 2 reading functionElthan_Huang2018-02-272-4/+13
| | | | | | | | | | | | | | | | | | | 1. Add reading function for remote2 temperature (Fintek, F75303) 2. Modify the temp_sensors to read sensor remote1 and remote2 for nami. BUG=b:72974136 BRANCH=none TEST=Verify Nami can get thermal remote 2 data by command "ectool temps all" Change-Id: I5e4a58f20089ed5690e2a084e93e7021e80afcdc Signed-off-by: Elthan_Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/910270 Commit-Ready: Raymond Chou <raymond_chou@compal.corp-partner.google.com> Tested-by: Raymond Chou <raymond_chou@compal.corp-partner.google.com> Reviewed-by: Raymond Chou <raymond_chou@compal.corp-partner.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
* charger/rt946x: Initialize earlierPhilip Chen2018-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | Thermal protection is by default enabled on rt946x, but we disable it in rt946x_init() and only rely on the fuel gauge to do thermal measurement. Thus when we init rt946x too late, rt946x could trigger thermal protection during boot and brown out the fuel gauge temporarily. BUG=b:72697658 BRANCH=scarlet TEST=boot scarlet rev3 w/o battery on AC and don't see VBAT drops Change-Id: I54eadd80bd4fd8a6e47309b13c4d46ee01dec04a Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/933703 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* battery/max17055: Report battery presence properlyPhilip Chen2018-02-261-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | For boards using max17055 and dumb battery, we can always read battery parameters from max17055 regs, even if the read values are out of whack. So it doesn't make sense to determine battery is present because we can read these parameters from max17055. Meanwhile, we have to set CONFIG.TSEL on max17055 as early as possible because this is required for max17055 to detect battery presense. BUG=b:72697658 BRANCH=scarlet TEST=boot scarlet rev3 w/o battery on Type-C/PD chargers Change-Id: Id190f0c2aa5bcd62dbe3edccca6460bf145cff01 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/933702 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* charger/rt946x: Disable charge timerPhilip Chen2018-02-142-0/+9
| | | | | | | | | | | | | | | | | If the charge timer expires, rt946x would stop charging. We don't need this function. BUG=b:72571372 BRANCH=scarlet TEST=read reg 0x12 and confirm TMR_EN == 0 Change-Id: I38137ac39c7e7dfd15f12342428708697f81922c Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/915501 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Philip Chen <philipchen@chromium.org> Reviewed-by: David Schneider <dnschneid@chromium.org>
* sn5s330: Disable vSafe0V interruptsEdward Hill2018-02-091-10/+11
| | | | | | | | | | | | | | | | | | | | | | | Turn off vSafe0V interrupts. They were not being handled or cleared causing the interrupt line to be stuck low after unplugging a USB device. Also don't use read-modify-write for INT_STATUS_REG4 since this would clear the dead battery mode bit before it has been checked. BUG=b:73076662 BRANCH=none TEST=unplug USB device, see USB_C1_SWCTL_INT_ODL=1 TEST=USB2 mouse can be connected multiple times, PPC VBUS detection works, BC1.2 chip turns on and off correctly (USB_C1_BC12_VBUS_ON_L). Change-Id: I96980ee330dd6e5f98e447e5e87f11dd60768a5d Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/909549 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* tcpm/fusb302: Wake charger task on VBUS level changePhilip Chen2018-02-081-0/+1
| | | | | | | | | | | | | | | | | We need to wake up charger task right after AC is plugged so that the charge state can be updated immediately. BUG=b:71520398 BRANCH=none TEST=Confirm charger task wakes up immediately when AC is plugged in a Scarlet in G3. Change-Id: I4a65b3da363cdc204b800bd300824dae616770cb Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/869419 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* driver/led/lm3630a: Disable Bank B, avoid race setting brightnessNicolas Boichat2018-02-071-9/+8
| | | | | | | | | | | | | | | | | | | | It is not necessary to enable Bank B, as we do not use it. Also, we have seen a race between enabling the banks and writing the brightness register to 0xFF, where the chip would reset the value after it has been set by EC. Adding a short 100us sleep fixes the issue. BRANCH=none BUG=b:69379749 TEST=Flash whiskers, pwm 0 50 works, even after a cold reset. Change-Id: Ic523a2475c3874c8433eb1b39e927793dd893e8f Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/906165 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Benjamin Gordon <bmgordon@chromium.org>
* charger/rt946x: Set up pre-charge currentPhilip Chen2018-02-062-0/+28
| | | | | | | | | | | | | | | | We should set up pre-charge current based on the battery pack we use. By default this parameter is 150mA. BUG=chromium:809246 BRANCH=none TEST=confirm IPREC register is written correctly Change-Id: I2cb0906c74bef144d80c38b5d15519d594ed42f2 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/902945 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* touchpad_elan: Power off when USB is suspended without wakeNicolas Boichat2018-02-051-2/+61
| | | | | | | | | | | | | | | | touchpad can be powered off when the USB interface is disabled without setting the remote wake feature (USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be ignored anyway. BRANCH=none BUG=b:72683995 TEST=touchpad is disabled when lid is closed. Change-Id: I688fce16ab8c75330e588ec130fb2aa499fc0ed1 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/897069 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ppc: Add Vconn and CC polarity settings.Aseda Aboagye2018-02-012-0/+39
| | | | | | | | | | | | | | | BUG=b:72292985 BRANCH=None TEST=Flash meowth; Verify with twinkie that Vconn is provided for a sink that requires it. Change-Id: I8168d2e4c46e04810dcf5c2898b2c337424eefec Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/888224 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* isl923x: Don't initialize ICL on sysjump.Aseda Aboagye2018-02-011-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ISL923x init function would initialize the charger's input current to the board's defined default. For some boards like meowth and zoombini, the default input current was set quite low, 128mA. When sysjumping, all HOOK_INITs are called again and therefore the input current limit would be reset even thought it would have been set correctly prior to jumping. Setting the current limit so low, without a battery, would cause a power failure and the PMIC would drop its power OK signal and go into emergency shutdown. This commit simply adds a check to whether the EC jumped to this image. If it has, the charger input current limit is left unchanged. It will be updated to the correct value by charge manager later on after determine the attached charge supplier. BUG=b:72129338 BRANCH=None TEST=Flash meowth; Boot to S0 without a battery; Verify that PMIC_DPWROK remains high. TEST=Repeat above test for zoombini. Change-Id: I7e5bbbbf3ec604c876cc4fa0163f8bb7feff4cc9 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/896960 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Caveh Jalali <caveh@google.com>
* cleanup: Correcting VBUS discharge commentJett Rink2018-02-011-1/+2
| | | | | | | | | | | BRANCH=none BUG=none TEST=none Change-Id: I0e7f21bd56a796d2261ffafa26f603924ac0d66d Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/896395 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* sn5s330: Enable VBUS interruptsEdward Hill2018-01-312-10/+45
| | | | | | | | | | | | | | | | | | | | | | | | | If the sn5s330 PPC is being used to detect VBUS presence (CONFIG_USB_PD_VBUS_DETECT_PPC), then enable interrupts and call usb_charger_vbus_change when VBUS_GOOD changes. BUG=b:72007153,b:72007492 BRANCH=none TEST=Connect 3A and 1A USB-A chargers to each of Grunt's USB-C ports, check that BC1.2 detection is working: With 1A: > chgsup port=0/1, type=7, cur=500mA, vtg=5000mV, lsm=1 With 3A: > chgsup port=0/1, type=7, cur=2400mA, vtg=5000mV, lsm=1 TEST=Boot Grunt to OS, then connect USB2 mouse or USB3 flash drive to each of Grunt's USB-C ports. Devices do not work due to b:71772180, but gpioget shows EC is setting USB_C0/1_BC12_VBUS_ON_L correctly. Change-Id: Iffc352105a321997adb364b9fbb8bafef248c224 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/887938 Reviewed-by: Jett Rink <jettrink@chromium.org>
* usb pd: Adding PPC vbus discharge pathJett Rink2018-01-312-0/+25
| | | | | | | | | | | | | | Boards with a PPC will use the PPC to discharge the VBUS line instead of the TCPC or GPIO discharge path. BRANCH=none BUG=b:72179253 TEST=Fall time after device removal on grunt within spec now Change-Id: I822923a1cedb32a20efc3610cce4437ade3387f0 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/886563 Reviewed-by: Edward Hill <ecgh@chromium.org>
* charger/rt946x: Reset VBUS by defaultPhilip Chen2018-01-301-0/+7
| | | | | | | | | | | | | | | | | | | | | In the system, RT946x is always powered by the battery. So even in battery cutoff mode, the reg values on RT946X are not reset. We don't want RT946x to supply VBUS when DUT boots, which could mess up PD state. So we need to disable VBUS output when RT946x initializes. BUG=b:72228350 BRANCH=none TEST=Confirm OPA_MODE (bit0 in reg 0x01) is clear after RT946x finishes initialization Change-Id: I32795b3bea64860b164c14b06aa1cd2551ebd8a0 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/890028 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org>
* charger/rt946x: Clear irq flags correctlyPhilip Chen2018-01-301-9/+9
| | | | | | | | | | | | | | | | | | | | | | rt946x_block_read() is not implemented right. It not only makes rt946x_init_irq() fail but also put RT946x i2c module in an erroneous state temporarily. BUG=b:72228350 BRANCH=none TEST=manually on scarlet rev3: 1)Insert Plugable USB-C hub w/o AC 2)Run cutoff command on ec console 3)Hold Pwr button for a few seconds to wake up DUT 4)Repeat 2 - 3 for 10 times without seeing PD loops Change-Id: I9304617f924e44288483afca5ab1b2923eb68ff0 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/890027 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org>
* charger/rt946x: Log the init failurePhilip Chen2018-01-301-2/+4
| | | | | | | | | | | | | | BUG=b:72228350 BRANCH=none TEST=See the error message when init fails Change-Id: Ib9b1906cb2d0b2427a96ea4823eb3325912f344b Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/890026 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org>
* Nami: Update for ALS and temperture sensorElmo_Lan2018-01-283-0/+97
| | | | | | | | | | | | | | | | | Implement ALS code and add a new thermal sensor (Fintek, F75303) BUG=b:71839392 BRANCH=none TEST=Verify Nami can read ALS and thermal data via I2C by ec console. Change-Id: I0f8fd486f62508bbca30a57f435b9f26621cf34b Signed-off-by: Elmo_Lan <elmo_lan@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/863350 Commit-Ready: Elmo Lan <elmo_lan@compal.corp-partner.google.com> Tested-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com>