summaryrefslogtreecommitdiff
path: root/common/usb_port_power_smart.c
Commit message (Collapse)AuthorAgeFilesLines
* usb_port_power_smart: Add support for IO expander GPIOsEdward Hill2019-10-251-10/+10
| | | | | | | | | | | | | | Allow CONFIG_USB_PORT_POWER_SMART GPIO signals to be either local GPIOs or IO expander GPIOs. BUG=b:138600691 BRANCH=none TEST=CONFIG_USB_PORT_POWER_SMART with IO expander signals works on Trembyle Change-Id: Ic5273926ec4f428586370175a136bff68900a323 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1854779 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* host_command: Change host command return value to enum ec_statusTom Hughes2019-10-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the host command handler callback function returns an int, it's easy to accidentally mix up the enum ec_error_list and enum ec_status types. The host commands always expect an enum ec_status type, so we change the return value to be of that explicit type. Compilation will then fail if you accidentally try to return an enum ec_error_list value. Ran the following commands and then manually fixed up a few remaining instances that were not caught: git grep --name-only 'static int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#static int \(.*\)(struct host_cmd_handler_args \*args)#\ static enum ec_status \1(struct host_cmd_handler_args \*args)##' git grep --name-only 'int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#int \(.*\)(struct host_cmd_handler_args \*args)#\ enum ec_status \1(struct host_cmd_handler_args \*args)##' BRANCH=none BUG=chromium:1004831 TEST=make buildall -j Cq-Depend: chrome-internal:1872675 Change-Id: Id93df9387ac53d016a1594dba86c6642babbfd1e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@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>
* usb_port_power_smart: support a new usb_charge_mode - USB_CHARGE_MODE_DEFAULT.Marco Chen2019-05-241-10/+3
| | | | | | | | | | | | | | | | | | | | | OS can leverage `ectool usbchargemode` to control the usb_charge_mode in the EC. In this case, we might want to set mode back to the default one defined in the config of board level therefore the new usb_charge_mode is added for this purpose. BUG=b:130767435 BRANCH=octopus TEST=1. make -j buildall 2. ectool usbchargemode 0 0x5 0 3. usb charging mode is set to CDP in Octopus board Change-Id: Ib7397993fc49e6c744dc55b9adace95dd6b8bd3a Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1621452 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* usb_port_power_smart: data of USB_SYSJUMP_TAG is a struct not uint8_t.Marco Chen2019-05-241-5/+8
| | | | | | | | | | | | | | | | | | BUG=b:130767435 BRANCH=octopus TEST=1. `make buildall -j4` 2. execute `ectool usbchargemode 0 2 1` in EC RO stage. 3. jump to EC RW stage. 4. check whether charge_mode in RW is restored well in usb_charge_init() Change-Id: I57346d3d92fa58a4d07b7509846123fc8f0c93fc Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1626890 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* usb_port_power_smart: turn on/off charging mode during system suspendZhuohao Lee2019-01-301-17/+52
| | | | | | | | | | | | | | | | 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>
* usb_port_power_smart: Add CDP/SDP only option.Aseda Aboagye2017-08-281-17/+27
| | | | | | | | | | | | | | | | | | | | | | | | | For some boards, the control lines to the charging port controller are all tied to a power rail. In essence, this leaves the ILIM_SEL as the only signal able to be controlled, which means that we only support CDP/SDP. This commit adds a new CONFIG_* option which describes this. CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY Additionally, some cleanup is made to not always assume the number of smart power ports. BUG=None BRANCH=None TEST=make -j buildall Change-Id: I080ccd67ffc20ccccf1e6b33a3cf9374a6b70ad6 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/634274 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* usb_port_power: Allow variable number of portsDaisuke Nojiri2017-05-011-31/+14
| | | | | | | | | | | | | | | | | Currently, usb_port_power_dumb allows fixed number of ports (2) and usb_port_power_smart allows less than 4 ports. This change removes the limitation and makes them accept variable number of ports. BUG=chromium:715178 BRANCH=none TEST=Verified usbchargemode returns consistent charge_mode across sysjumps on Electro. Change-Id: I7675c65ba03d3e6f7f53b2fe48cbe510231d945a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/481077 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* USB: Remove usb_charge_ports_enabledDaisuke Nojiri2017-04-201-19/+0
| | | | | | | | | | | | | usb_charge_ports_enabled is not used. BUG=none BRANCH=none TEST=make buildall Change-Id: I9465b65e9fab2603a4258adc4ae5f16d6bfc93c4 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/481076 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* usb: power_smart: Allow CONFIG_USB_PORT_POWER_SMART_PORT_COUNT < 2Shawn Nematbakhsh2016-09-221-2/+8
| | | | | | | | | | | | | | | | Don't require GPIO_USB2_ENABLE to be defined if we have only one port. BUG=None TEST=Redefine CONFIG_USB_PORT_POWER_SMART_PORT_COUNT to 1 for reef, remove GPIO_USB2_ENABLE definition, verify build is successful. BRANCH=None Change-Id: I5bfbee48ceabd87bbbd45cb120fda320d5eb1897 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/387926 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* cleanup: DECLARE_CONSOLE_COMMAND only needs 4 argsBill Richardson2016-08-241-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since pretty much always, we've declared console commands to take a "longhelp" argument with detailed explanations of what the command does. But since almost as long, we've never actually used that argument for anything - we just silently throw it away in the macro. There's only one command (usbchargemode) that even thinks it defines that argument. We're never going to use this, let's just get rid of it. BUG=none BRANCH=none CQ-DEPEND=CL:*279060 CQ-DEPEND=CL:*279158 CQ-DEPEND=CL:*279037 TEST=make buildall; tested on Cr50 hardware Everything builds. Since we never used this arg anyway, there had better not be any difference in the result. Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/374163 Reviewed-by: Myles Watson <mylesgw@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* usb_port_power_smart: Support variable port countchris wang2016-03-241-25/+32
| | | | | | | | | | | | | | | | | | | | Use CONFIG_USB_PORT_POWER_SMART_PORT_COUNT to support more usb ports (default 2). BUG=None BRANCH=firmware-strago-7287.B TEST=build&flash ec,verify on wizpig,usb function work Signed-off-by: Chris Wang <chriswang@ami.com.tw> Change-Id: I2460d4a5755ef457249d728169c27fc6d00625d2 Reviewed-on: https://chromium-review.googlesource.com/333232 Reviewed-by: Shawn N <shawnn@chromium.org> Tested-by: lehai deng <denglehai@ithaier.com> Commit-Queue: Chris Wang <chriswang@ami.com.tw> Tested-by: Chris Wang <chriswang@ami.com.tw> (cherry picked from commit 1e7d3554f1bedbb839a0f4800286c9db0d27e4f1) Reviewed-on: https://chromium-review.googlesource.com/334510 Commit-Ready: Chris Wang <chriswang@ami.com.tw>
* Support inverted ILIM_SEL for smart USB port powerDuncan Laurie2014-08-231-2/+9
| | | | | | | | | | | | | | Some platforms may have active low ILIM_SEL that is per-port and the output needs to be inverted. BUG=chrome-os-partner:31549 BRANCH=samus TEST=emerge-samus chromeos-ec, not used until EVT Change-Id: I1e164d9aa46df119467113eb175e7deec4fd8a21 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/213743 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* USB Power: Add config option to set default charge modeDave Parker2014-07-171-2/+6
| | | | | | | | | | | | | | | BUG=chrome-os-partner:29053 BRANCH=ToT TEST=Set a default change mode other than SDP2 in a board config. Verify the 'usbchargemode' console command indicates the ports are operating in that mode. Change-Id: I0d572df726c4bb42d0ff5f40c06d8ea73e406283 Signed-off-by: Dave Parker <dparker@chromium.org> Origianl-Change-Id: I4a65d8b6ad14ff3d1f12b644960bbf401027f8df Reviewed-on: https://chromium-review.googlesource.com/205812 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/208162
* USB Power: Invert ILIM control line with 'smart simple' chargingDave Parker2014-07-171-3/+3
| | | | | | | | | | | | | | | | | | | The ILIM control line is inverted before reaching the USB charge controllers when they are cross-connected to allow only one port to deliver the HIGH current limit at a time. BUG=chrome-os-partner:29053 BRANCH=ToT TEST=Verify, with a multimeter, that ILIM (pin 4) on a TPS2546 is 3.3V when the chargemode is set to CDP Change-Id: I2f720d04b959417ae96687d7e30ee60270eeccb9 Original-Change-Id: Idd89dcfc117f1f3393ded1887e8d1cb27ba367ad Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/205811 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/208161
* Add cprints() and ccprints()Vic Yang2014-05-211-2/+2
| | | | | | | | | | | | | | | | | | | | | 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>
* rambi: Leave 5V rail on in S3 if USB ports are poweredRandall Spangler2014-01-231-0/+13
| | | | | | | | | | | | | | | | | Previously, the 5V rail was disabled unconditionally in the S0->S3 transition. Now, the rail is left powered if one or both of the USB ports are powered. BUG=chrome-os-partner:25178 BRANCH=rambi TEST=Modify the OS to leave USB ports powered in S3. Then suspend. On the EC console, 'gpioget pp5000_en' should be 1. Change-Id: I3c73f3fe228e940317c0da7330f117c7ab0a6d0c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/183548 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* rambi: Add config option for simplified USB power controlRandall Spangler2014-01-071-6/+6
| | | | | | | | | | | | | | It will be used by all variants of Rambi, so #ifdef BOARD_RAMBI is too restrictive. BUG=chrome-os-partner:24864 BRANCH=rambi TEST=boot rambi 1.5 board; plug in USB mouse Change-Id: I0ff02077388a6c6621c5746a693dde894cf8ad77 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/181682 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* Rename mixed-case config constantsRandall Spangler2013-12-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This renames constants used in compiler conditionals to uppercase. BOARD_foo CHIP_foo CHIP_FAMILY_foo CHIP_VARIANT_foo CORE_foo Mixed-case constants are still defined by the makefile, but are now no longer used. I will make one more pass in a week or so to catch any that are part of someone else's CL, since otherwise this change might silently merge correctly but result in incorrect compilation. Then I will remove defining the mixed-case constants. BUG=chromium:322144 BRANCH=none TEST=Build all boards. Also, "git grep 'BOARD_[a-z]'" should return no results (similarly for CHIP, CORE, etc.) Change-Id: I6418412e9f7ec604a35c2d426d12475dd83e7076 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/179206 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Pad jump tags to 4 bytes inside the system moduleRandall Spangler2013-11-051-2/+0
| | | | | | | | | | | | | | | | | | | | | | | That way all the users of jump tags don't need to know about the padding requirements. BUG=chrome-os-partner:23851 BRANCH=none TEST=enable CONFIG_CMD_JUMPTAGS, then 'jumptags'. Output should be something like this: 20007fbc: 0x5550 UP.1 2 20007fc4: 0x4b42 KB.2 3 20007fcc: 0x4c50 LP.1 12 20007fdc: 0x4d54 MT.1 8 All the addresses in the first column should be word-aligned. The sizes in the last column don't need to be a multiple of 4. Change-Id: I91f9c29701a007ef8a56b5b7e0ea09930dfbea31 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/175591 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* rambi: Support USB port power controlRandall Spangler2013-10-211-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Rambi shares several of the control signals (CTL1, ILIM_SEL) between both ports, and hard-wires some of the others (CTL2, CTL3). It still has separate enable lines for each port. BUG=chrome-os-partner:18343 BRANCH=none TEST=boot system; gpioget shows (in part) 1 USB_CTL1 0 USB_ILIM_SEL 1 USB1_ENABLE 1 USB2_ENABLE Then do 'apshutdown' and gpioget shows 1 USB_CTL1 0 USB_ILIM_SEL 0 USB1_ENABLE 0 USB2_ENABLE Change-Id: Ib3d321ca2b0aa7dce08ddd6633810a75641bc9a8 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/173737 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org>
* Internalize magic numbers for smart USB chargingBill Richardson2013-10-021-1/+4
| | | | | | | | | | | | | | | | | | | | | Link is the only platform that uses smart usb ports. Link's board.h defines USB_CHARGE_PORT_COUNT, yet the usb_port_power_smart.c file is peppered with assumptions that that constant is always 2. This moves the constant into usb_port_power_smart.c where it belongs. BUG=chrome-os-partner:18343 BRANCH=none TEST=manual make runtests Code refactoring only, no visible changes, Change-Id: Id45e11d88585a98348105b1399c7e18c554add50 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/171565 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Split the USB port power control into smart and dumb versions.Bill Richardson2013-05-011-0/+202
Also renaming to avoid confusion as to what's being charged. BUG=chrome-os-partner:18825 BRANCH=slippy TEST=manual Build everything, Link still works. Change-Id: I4205a1210c7dfe57cfbbdd740970ef57e6a011b8 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49775 Reviewed-by: Randall Spangler <rspangler@chromium.org>