Commit Graph

57 Commits

Author SHA1 Message Date
Randall Spangler
6b8e8be703 Fix discovery and bds builds, which don't have temp sensor or peci
Remove id field from temp_sensor_t struct, since it's only used by the
console command (which already knows the id, because it's looping over
it).

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST='temps'

Change-Id: I0970850073d644509cd5501d7ac4421c7373143b
2012-02-13 10:41:34 -08:00
Bill Richardson
3b02beb41c Merge "Make strtoi() do the right thing for base==16" 2012-02-10 16:33:40 -08:00
Rong Chang
62df62ccd4 Add basic smart battery driver
This change adds a common part of smart battery driver. Following
features are not implemented, or in chip specific driver:
  Battery access control, authentication, factory mode
  Manufacturer access/data commands
  Block read/write, device name, flash data
  Chip specific features, per cell info/temp/capacity

Signed-off-by: Rong Chang <rongchang@google.com>
BUG=chrome-os-partner:7856
TEST=console command check battery staus
  [unplug power]
  > battery
  [check voltage,current,capacity,time to empty]
  [plug power]
  > charger voltage 8400
  > charger current 4250
  > battery
  [check current,time to full]
  > charger input 4032
  > battery
  [check current,time to full]
  [wait 130 seconds, charger watch dog timeout]
  > battery
  [check current]

Change-Id: Ifac17a0892f52e8f37eebc14b00e71f18360776c
Signed-off-by: Rong Chang <rongchang@chromium.org>
2012-02-10 16:12:56 -08:00
Bill Richardson
6e1cdb7898 Make strtoi() do the right thing for base==16
Before, strtoi("11", 0, 16) returned 11.
Now, strtoi("11", 0, 16) returns 17.

BUG=none
TEST=none
2012-02-10 16:11:30 -08:00
Randall Spangler
6063ad473c Add PECI module and CPU temperature monitoring
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7493
TEST='powerbtn' to boot main processor, then 'temps' and 'pecitemp'

Change-Id: Id57526ebb37c8aecb05ecebccc2824f462b9de1a
2012-02-10 14:09:42 -08:00
Louis Yung-Chieh Lo
186c81dcac Send scan code to host when power button is pressed/released.
But only if the system is in S0.

Approved at internal gerrit: 11595.

BUG=none
TEST=tested on bds.
2012-02-10 12:11:42 +08:00
Randall Spangler
e42cd379de Print repeated port 80 writes, for coreboot/uboot debugging
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7972
TEST=boot main processor; look for repeated sequential port 80 writes

Change-Id: I07b247130945296ce73177a342e0b2cf5645f4fb
2012-02-09 11:00:11 -08:00
chrome-bot
898aaf1914 Merge "Add tmp006 object temperature calculation" 2012-02-08 17:59:11 -08:00
Vic Yang
059c633a27 Add tmp006 object temperature calculation
Implement TMP006 object temperature calculation. Also add a console
command to calculate temperature with manually entered data.

BUG=chrome-os-partner:7801
TEST=In console, "tempremote 29715 -105000 6390" gives 285.00K.

Change-Id: I0f9193fb970fdc36566399e7083e73ab58965a85
2012-02-08 14:53:17 +08:00
Rong Chang
61e995edaa Fix charger init crash
The current calculation was wrong in previous code import. This CL
fixes current calculation, remove init input current setting, and
adds charger set commands.

Signed-off-by: Rong Chang <rongchang@google.com>
BUG=chrome-os-partner:7855
TEST=build and flash link image, run following commands:
    charger
    charger voltage 4096
    charger current 128
    charger input 4032
    charger

Change-Id: I156ffac9f03d490475088c430232622a12b9ec29
2012-02-07 18:06:20 -08:00
chrome-bot
16df421edc Merge "Initial bq24725 charger driver import" 2012-02-07 16:15:16 -08:00
Randall Spangler
7423b63ea3 More complete x86 power module
Supports turning system on and off via power button.

Also added 'powerbtn' command, which sends a power button press of the
specified duration, and deprecated the 'x86power s0' command, since
pressing the power button is a more correct way of powering on/off the
system.

Note that current coreboot doesn't seem to boot reliably; when it
fails, the x86 asks for S5 and then S0 a second later.  It boots about
every 3rd try.  No indication this is due to the EC; the EC just was
ignoring these requests until this CL.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7851
TEST=reboot, 'powerbtn', system should power on
'powerbtn', system should power off
'powerbtn 5000', system should power off regardless of previous state
press power button, system should power on
press power button again, system should power off
hold power button 8 sec, system should power off regardless of previous state

Change-Id: I89f419553289b20c78a57bc8cb1699932b095aa1
2012-02-07 15:01:50 -08:00
Rong Chang
812b3f8cb6 Initial bq24725 charger driver import
Battery charging state machine contains many file changes.
This is the 1st part of the break down. Refactor original
test code into board dummy driver. Normalize charger API.
And import link's charger IC driver.

Signed-off-by: Rong Chang <rongchang@google.com>
BUG=chrome-os-partner:7855
TEST=build without warning and error
  BOARD=bds make
  BOARD=link make
  BOARD=discovery make

Change-Id: I34b6e9862a45331378916bc77653d4adb22ca548
2012-02-07 12:54:28 -08:00
Randall Spangler
f214e47717 Turn on when power button pressed
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7850
TEST=reboot, press power button; system should turn on
reboot, type 'x86power s0'; system should also turn on

Change-Id: Iac114c2655240d8aba81283d12f667f8e64d3ad3
2012-02-07 10:33:42 -08:00
Vic Yang
730f099c83 Handle up/down arrow keys for UART console.
Record commands used previously and use up/down arrow key to navigate in
the command history.
Also removed the command '.' of repeating last command as we can use up
arrow key now.

Also changed the behaviour of uart_write_char() to be blocking on
transmit FIFO full, so that we do not lose echoed character and do not
need to flush.

BUG=chrome-os-partner:7815
TEST=Type 'help' and enter. Then type 'aaaa' and up arrow key, should
show 'help', and pressing enter prints help.
Type 'hellp' and enter. Then type 'aaaaaa' and up arrow key, should show
'hellp'. Should be able to use left/right arrow key and backspace to
correct it to 'help', and pressing enter prints help.
Type 'help' and enter. Then type 'aaa', up arrow key, and down arrow
key. Should show 'aaa'.

Change-Id: I65c615d61bf63acb31bea329aa91a3202d4db0ad
2012-02-07 10:23:59 +08:00
chrome-bot
d3e1de758c Merge "Additional compilation fix-ups for non-LM4 targets" 2012-02-06 17:03:28 -08:00
David Hendricks
53c1c20fb8 Additional compilation fix-ups for non-LM4 targets
- Add #ifdef CONFIG_TEMP_SENSOR before #include'ing temp_sensor.h
  which actually requires temp_sensor_id to be defined.
  Revert the forward declare used earlier since it is not the
  correct solution in this case.
- Add #ifdef CONFIG_CHARGER before calling charger_init()

Signed-off-by: David Hendricks <dhendrix@chromium.org>

BUG=None
TEST=compiled on both BDS and Discovery

Change-Id: I60b7e4ba91eb958b3ad724cc9ffa9a12fe9c3a71
2012-02-06 15:40:23 -08:00
Randall Spangler
99b297f990 Merge "Increase simulated power button duration in x86power s0 command" 2012-02-06 15:35:32 -08:00
Randall Spangler
4a7bfe7c43 Increase simulated power button duration in x86power s0 command
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7906
TEST=from ec console, 'x86power s0' should power the system on reliably.

Change-Id: Idebfc8b4e86587b540934d245649f912ccb4aa95
2012-02-06 15:02:57 -08:00
Louis Yung-Chieh Lo
6409913523 Fix some scancodes: F1-F10, arrow keys, and search key.
F1-F7: swap scancode of set 1 and set 2
F8-F10: change from (F9, F10, F11)
arrow keys: swap scancode of set 1 and set 2
Search key: change from CapsLock key

BUG=none
TEST=tested on bds.

Change-Id: Ifb8e715a2cd5f8ea174f7c38647c5ce550382615
2012-02-06 23:15:59 +08:00
Louis Yung-Chieh Lo
d2fc22dcad Uses update_ctl_ram() in 'ctrlram' command.
BUG=none
TEST=tested on bds.

Change-Id: I564e1be8201558d755636205157a6f1c581ec0dc
2012-02-06 22:20:32 +08:00
Louis Yung-Chieh Lo
e3fa162827 Add ctrlram command to get/set controller RAM content.
BUG=none
TEST=tested on bds.

Change-Id: Ibfabf2c35d19c231f3ebe860877b9f4020b0f870
2012-02-06 12:21:53 +08:00
Vic Yang
000a6d5742 Refactor temperature sensor code and add support of Link I2C temp sensor.
Refactor board/chip-specific code into corresponding directories.
Add support of the four I2C temp sensor in Link.
Use table lookup to handle different types of temperature sensors.

BUG=chrome-os-partner:7527
TEST=Correctly read EC internal temperature on bds.
Compile for link succeeded.

Change-Id: I694cfa54e1545798d877fafdf18c5585ab5f03e2
2012-02-04 14:37:04 +08:00
Vincent Palatin
a72b9cc07e Split out GPIO console commands
The GPIO console commands are common to all platform, let's push them in
the common code.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=make BOARD=link && make BOARD=bds && make BOARD=discovery
on BDS console, try gpioget command.

Change-Id: I26e6d26b8d661e78b80d5d5f665e81f4daef0c11
2012-02-03 02:00:27 +00:00
Vincent Palatin
55f990cd0f Fix image copy detection
When the flash base address is not zero (e.g. STM32L chip), the current
image index is wrongly computed.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=check it compiles for all boards, run on Discovery board and see
proper value.

Change-Id: I06f5508cdffce6d754bd93e870d64087d299c9c7
2012-02-02 19:15:06 +00:00
Louis Yung-Chieh Lo
7e8d739b38 Fix the missing IRQ problem.
The problem comes from the different assumption of interrupt mode in EC and
the PCH. The PCH assumes IRQ1 is edge-triggered and triggered at a rising edge.
However, the auto-IRQ functino of EC is level-triggered and uses low-active to
assert an IRQ. This makes the deadlock so that the kernel never gets an
interrupt until a byte is manually pulled from host.

So, the solution is manually firing an IRQ_1 to host after EC puts a byte to
port 0x60. Note that the auto IRQ needs to be disabled in order to avoid
the interference with manual IRQ generation.

This CL also moves chip specific code to lm4/lpc.c and handle some minor
keyboard commands.

BUG=none
TEST=on hacked baord.

Change-Id: Ib57f5a4d749cb019e4c3c00da110054c4f335c7b
2012-02-02 20:51:45 +08:00
Vic Yang
1a10681369 Handle left and right arrow key in UART console.
Handle left and right arrow key to move cursor around.
Other escape sequences are still ignored.

BUG=chrome-os-partner:7865
TEST=type some text and use left and right arrow key. Cursor should
move.
type 'hellp', left key, and backspace. Should show 'help' and hitting
enter prints help.
type 'hexp', left key, backspace, 'l'. Should show 'help and hitting
enter prints help.

Change-Id: If9ac4504c56f023f824175de2daf565ce72d4560
2012-02-01 10:35:36 +08:00
Randall Spangler
05bc7eca93 Eat terminal escape sequences
I keep hitting the darn arrow keys.  Until we can do something more
elegant like a real command history, this will at least keep me from
corrupting the display and input buffer.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=type 'help' and some arrow keys, then enter.  Should print help, not an error.

Change-Id: Idb552e9c22876fc2dc1f349f0038e94048f00aa7
2012-01-27 13:58:49 -08:00
Randall Spangler
a643b6216c Track the remaining GPIOs from the PCH
To assist in x86 chipset bringup, there are 4 GPIOs we weren't
printing state transitions for.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=reboot; should see state transitions in the high nibble (mask 0xF000), for example:
  [x86 power state 1 = S5, in 0x2001]
  [x86 power state 1 = S5, in 0x3001]
  [x86 power state 1 = S5, in 0x7001]

Change-Id: I0527e4698425d845e8b08589e89592f95d8bee41
2012-01-27 13:18:00 -08:00
chrome-bot
36050a30d5 Merge "Split reset cause and image copy code." 2012-01-26 16:47:44 -08:00
chrome-bot
833cd5d68b Merge "Split UART code" 2012-01-26 16:47:44 -08:00
Randall Spangler
d12a96a5ec Add x86power command to get/set x86 power state
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7528
TEST=x86power s0; should turn on all power rails (check via gpioget)

Change-Id: I284ac2104e02748ed69408873fbcebb9d54cdcff
2012-01-26 16:01:39 -08:00
Vincent Palatin
84dc68283e Split reset cause and image copy code.
Preparatory work to introduce a second SoC : 3rd series 2/2

All the RO/A/B firmware copy code could be generic to all our platforms.
The console commands are a 'standard' API.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=on BDS EC console, check the reset cause with the 'sysinfo' command.

Change-Id: Ieeb84571085d88b5747a09da4c33d3852bb0da96
2012-01-26 22:34:41 +00:00
Vincent Palatin
53eaf213d5 Split UART code
Preparatory work to introduce a second SoC : 3rd series 1/2

Most of the code is handling the buffering and the printf, thus put it
in an hardware independant location and only implement the UART
dependant portions in the chip driver.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=run on BDS and stress the console.

Change-Id: I9376f2fa1dad341eac808e1756dbeff32900bd51
2012-01-26 22:07:00 +00:00
Vincent Palatin
1f00fc154a Make more features optional
Preparatory work to introduce a second SoC : 2nd series 3/4

Some modules won't be used on other designs, make them optional.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=run the EC firmware on BDS and check that the commands from the
optional features are still available and working.

Change-Id: I979864ed94dc4da90c1010bd2e4589d84bc2d046
2012-01-26 01:55:37 +00:00
Vincent Palatin
1008124533 Remove useless header includes
Preparatory work to introduce a second SoC : 2nd series 2/4

Avoid introducing platform specific dependencies in common files where
they are not necessary.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=build for BDS and Link

Change-Id: If2ccd022e4956425222b55a5a48ca7522857e7f0
2012-01-26 01:32:30 +00:00
Vincent Palatin
d356dea61e Add modularity to the build
You can now enable/disable tasks more easily.
To conditionally compile a C file depending on the task FOO activation,
just write something like that in the build.mk file :
common-$(CONFIG_TASK_FOO)+=foo_source.o

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=make all BOARD=link && make qemu-tests

Change-Id: I760fb248e1599d13190ccd937a68ef47da17b510
2012-01-24 23:17:07 +00:00
Randall Spangler
8c56cc4fa7 Help command prints a sorted multi-column list of commands
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=type 'help' from console

Change-Id: If88610f35337243ca2550de2851bd1924083344d
2012-01-24 10:32:29 -08:00
Vincent Palatin
c21f07e58e register console commands at compile-time
Instead of using a runtime callback to register the console commands,
put them in a special linker section. So we can do a macro to "register"
them during the build.

It saves 684 bytes and a few microseconds at startup.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=run a few commands from the BDS command line.

Change-Id: Id33ea210b9035bf76ed720373c74c5dd24ccd1b1
2012-01-24 00:50:08 +00:00
Randall Spangler
cdc3fbf2cf Calibrate internal oscillator using hibernate clock
This works around a chip errata where the internal oscillator on early
EC parts (as used on proto0) is untrimmed.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7693
TEST=if it runs, it works

Change-Id: Ie82a524543f4cf25efd0de7998dbdae103bd126b
2012-01-23 14:58:56 -08:00
Vic Yang
af8026cdf9 USB Charging control
Implement TPS2543 USB charging control.
It contains routine for setting each USB port as dedicated charging port
or standard downstream port. To allow us controlling the current
distributed to each port, we can select whether to allow 500mA or 1500mA
for each port.

BUG=chrome-os-partner:7476
TEST=Added USB port definition for BDS and tested GPIO output voltage
level is correct for all modes.

Change-Id: I19bc4b30d333aa802f868ebfc3a398b30e99ba0f
2012-01-19 10:54:37 +08:00
Randall Spangler
002bc4278b Add x86 power state machine
For bringup, this powers on the x86 unconditionally.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7528
TEST=none

Change-Id: Ib23e56d38ab42f8d8a4dbd1ba9dce12f0c3eeec9
2012-01-17 12:19:47 -08:00
Randall Spangler
70a9928add Configure all GPIOs
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7528
TEST=none

Change-Id: I0a9be4c689fb72507edcf202073b23c58902d7de
2012-01-12 15:54:35 -08:00
Randall Spangler
c9352ce6ca Add constants for all GPIOs.
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7528
TEST=none

Change-Id: I3b77cbbb7f0cc12a4daae7ababd603b5d7af32d1
2012-01-11 16:30:56 -08:00
Randall Spangler
1f2f8627c3 Add JTAG module
This just ensures the JTAG pins are reset to JTAG function on warm reboot.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7448
TEST=none

Change-Id: I0cccdbe7a68c228db7f354898ed30598e9fabff0
2012-01-11 11:37:55 -08:00
Randall Spangler
39f86d2fad Split power button code into its own file
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7499
TEST=press and release power button; should see debug messages

Change-Id: I8909ae4643afc98753edb690771618ad43135e3e
2012-01-10 14:14:59 -08:00
Randall Spangler
55ffdb465b Clean up labels and TODOs
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=none

Change-Id: I8d6e99b3e2b60d32ea3719468590b055e692a67e
2012-01-10 10:31:56 -08:00
Vic Yang
ee6206be1d Fix an error in common/build.mk that causes compilation fail.
Removed a duplicated line in common/build.mk which causes compilation
fail.

BUG=chrome-os-partner:7313
TEST=Compilation passed

Change-Id: Ia7bb73b96e4feae27e5b6e519feb3ea1a672913a
2011-12-28 10:14:34 +08:00
Vic Yang
e98b6befca Add EC host command to control fan speed.
Add LPC host command to get and set fan speed.

BUG=chrome-os-partner:7313
TEST=Connect a fan and manually test fan actual speed matches target
speed.

Change-Id: I4b6a711a1b8cca0dbd1c1936fe4f0f15240d3453
2011-12-27 10:14:29 +08:00
Vic Yang
b228bc14c0 Add host command to read temperature sensor value
Add a LPC host command to read temperature sensor value with given
sensor id.
Add ectool command to read temperature sensor value through LPC.

BUG=chrome-os-partner:7329
TEST=Manual check the reading received is the same as value printed by
console command.

Change-Id: Id3386774435be6c3ae010a143f4fa894568efdb8
2011-12-22 13:51:07 +08:00