Commit Graph

13 Commits

Author SHA1 Message Date
Alec Berg
28d4565d8e i2c: allow for mulitple i2c busses to utilize automatic unwedging
Previously we had a restriction that only one i2c bus could use the
automatic wedge detect and unwedge functionality. This removes that
restriction, although it uses a mutex to make sure only one bus is
being unwedged at any given time.

BUG=chrome-os-partner:26485
BRANCH=samus
TEST=make -j buildall

Change-Id: I8ff238fb8a9e9d2f5bc57a2b0a05e2b231024772
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220466
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Commit-Queue: Duncan Laurie <dlaurie@chromium.org>
2014-09-30 08:32:23 +00:00
Vic Yang
a9b0d15e6e I2C console command bug fix
We are now using argv[5] even if the user only gives 5 arguments. Fix
it.

BUG=None
TEST=Read with i2cxfer command and doesn't see "Invalid param 5"
BRANCH=None (this can be worked around by adding a dummy param)

Change-Id: Ice13fec4ad53c71b6529daa3510fa6fc1d7f8c00
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/208489
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-07-17 06:55:01 +00:00
Randall Spangler
88295aca5a i2c: remove (lack of) 10-bit support in i2c passthru
We never implemented this.  We have no devices which support it.  And
we used bit #17 in a 16-bit field to flag it, so it wouldn't have
worked even if we did.  So, remove this (dead) code.

BUG=chromium:382944
BRANCH=none
TEST=make -j buildall

Change-Id: Id3a4a93612d1078a3239d85921a05cfd7362b84c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204162
Reviewed-by: Doug Anderson <dianders@chromium.org>
2014-06-17 12:15:57 +00:00
Vic Yang
ffac23c0ea Add cprints() and ccprints()
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>
2014-05-21 20:32:17 +00:00
Louis Yung-Chieh Lo
4ba7a1502d cleanup: add square brackets to make test parser easier
This may not contain all. I filtered out possible code by the
following command:

  find . -name "*.h*" -o -name "*.c*" | xargs grep -n CPRINTF |  \
      grep -v "\[" | grep -v define | less

BUG=none
BRANCH=none
TEST=make buildall tuntests

Change-Id: I674f84f5966b34aeb8d4321d22629b450627a120
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/197997
2014-05-07 03:41:22 +00:00
Louis Yung-Chieh Lo
3ac560d41b battery: don't talk to battery after cut-off
Add a shortcut in smart battery driver and i2c passthru. Once
the battery cut-off order is submitted (in the factory line),
the EC will no longer talk to battery.

BUG=chrome-os-partner:28248
BRANCH=tot,nyan
TEST=See below
> remove AC, cutoff: expect system is off.
> cutoff, then remove AC: expect system is off.
> cutoff, wait for 1 min, then remove AC: expect system is off.

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>

Change-Id: Ied963c19d17d581ce99e4543469cf2fa165f0439
Reviewed-on: https://chromium-review.googlesource.com/196657
Tested-by: Yung-chieh Lo <yjlou@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Yung-chieh Lo <yjlou@chromium.org>
2014-04-25 03:41:58 +00:00
Alec Berg
8a9817a5c7 cleanup: Combined i2c unwedge code into one common function
Refactored the i2c unwedge code to place it in the common directory
so that any EC chip can use it.

Added to the STM32F and LM4 boards, code to automatically detect and
unwedge the i2c bus at the start of an i2c transaction. Note that STM32L
already had this ability.

To enable unwedging of the i2c port though, the gpio pins for SDA and
SCL must be defined in the i2c_ports[] array in the board.c file. This
allows the i2c module to bit bang the unwedging for the given port. If
SDA and SCL are not defined for the port, then the unwedge code will
not run.

BUG=chrome-os-partner:26315, chrome-os-partner:23802
BRANCH=none
TEST=Manual testing on machines with different EC chips.

Testing made extensive use of https://chromium-review.googlesource.com/66389
in order to force wedging of the i2c bus so that we can attempt to unwedge
it. Note that you can easily test if the bus is wedged by running i2cscan.

On pit and spring:
On pit, after each of the following, I verified that the bus was automatically
unwedged.
On spring, the unwedge only runs at reboot, so, for the non-reboot wedge
commands, I manually ran console command unwedge, and verified that the bus
became unwedged.
(1) Bit bang a transaction but only read part of the response.
    Command to wedge: i2cwedge 0x90 0 2 2
(2) Bit bang a transaction to do a "write" and stop while the other side is
    acking. Command to wedge: i2cwedge 0x90 0 1
(3) Same as (1) but do a reboot instead of returning and see
    that the unwedge works at init time w/ no cancelled transactions.
    Command to wedge: i2cwedge 0x90 0 6 2
(4) Same as (2) but do a reboot instead of returning and see
    that the unwedge works at init time w/ no cancelled transactions.
    Command to wedge: i2cwedge 0x90 0 5

On glimmer:
Added code to call i2c_unwedge in accel_init(). Then tested unwedging the
accelerometer with the following. One extra difficulty testing this with
the accelerometer is that sometimes the bit you stop on is high, which
means it won't be wedged at all, the next start transaction will reset
the bus. So, sometimes running i2cwedge won't wedge the bus and sometimes
it will depending on the acceleration data.
(1) Big bang transaction to do a "read" of accelerometer and stop partway:
    i2cwedge 0x1c 0x0f 2 2
    i2cscan to make sure bus is actually wedged
    i2cunwedge
    i2cscan to make sure bus is now unwedged.
(2) Bit bang transaction to do a "read" and stop partway, then reboot:
    i2cwedge 0x1c 0x0f 6 2.
    i2cscan to verify that the bus is working after the reboot.

Change-Id: Ie3328e843ffb40f5001c96626fea131c0f9ad9b1
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/188422
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-03-06 02:42:49 +00:00
Randall Spangler
a35bfd69e9 Add arbitrary-length read support to i2cxfer
Previously, it could only read 8 or 16 bit values

BUG=chrome-os-partner:26191
BRANCH=rambi
TEST=manual

  Counted string for battery manufacturer name:
  > i2cxfer rlen 0 0x16 0x20 16
  Data: 0653696d706c6fe1e1e1e1e1e1e1e1e1

  Read lifetime data block 1 (also tests 16-bit writes)
  > i2cxfer w16 0 0x16 0 0x60
  > i2cxfer rlen 0 0x16 0x23 32
  Data: 20d2d2d2d2948700000d0a0a060a000000020000000000000000000000000000

  Read lifetime data block 2
  > i2cxfer w16 0 0x16 0 0x61
  > i2cxfer rlen 0 0x16 0x23 27
  Data: 1b0000000000010200010c02000201000100000300002008082009

  8 and 16 bit reads still work
  > i2cxfer r 0 0x16 0x23
  0x1b [27]
  > i2cxfer r16 0 0x16 0x23
  0x001b [27]

Change-Id: Ibba5aced60c0b2de04c3f86cf5fd2ab3db1b6308
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/188379
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-03-01 02:38:30 +00:00
ChromeOS Developer
aa636df6ab Check for valid i2c port number on i2c host commands
BUG=chrome-os-partner:25052
BRANCH=baytrail
TEST=Run ectool i2cread, i2cwrite, and i2cxfer commands
with invalid port numbers. Verify machine doesn't reboot.

Change-Id: Ifef062cb4a7548278f69689072324704f2f66317
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/182911
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-01-28 02:43:55 +00:00
Randall Spangler
6ab8e91658 cleanup: Remove checkpatch warnings
This make minor syntactic changes and renames some camel-cased symbols
to keep checkpatch from complaining.  The goal is to reduce the
temptation to use 'repo upload --no-verify'.

This is a big furball of find/replace, but no functional changes.

BUG=chromium:322144
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I0269b7dd95836ef9a6e33f88c003ab0f24f842a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180495
2013-12-19 00:12:28 +00:00
Randall Spangler
05bd0cdec7 Rename mixed-case config constants
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>
2013-12-16 20:28:32 +00:00
Randall Spangler
c0fbbaefed cleanup: comments in i2c modules
No code changes; just update comments with bug links

BUG=none
BRANCH=none
TEST=build all platforms

Change-Id: I8b845f9c43315b7db5a746a16c6618c3ee96979d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/174614
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-25 01:32:31 +00:00
Randall Spangler
8cf03ac056 Move source files to driver/ and power/ subdirs
The common/ subdir was getting cluttered.  Move drivers for external
components to a new driver/ tree, and move what used to be called
chipset_*.c to a new power/ directory.

This does not move/rename header files or CONFIG options.  That will
be done in subsequent steps, since moving and modifying .c files in
the same CL is harder to review.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I67a3003dc8564783a320335cf0e9620a21982d5e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173601
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-10-23 20:07:25 +00:00