Commit Graph

116 Commits

Author SHA1 Message Date
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
chrome-bot
249467b9f2 Merge "Use udelay for more stable manual IRQ firing." 2012-02-03 00:45:52 -08:00
Louis Yung-Chieh Lo
088b79f285 Use udelay for more stable manual IRQ firing.
Original code tests SND bit, but it is not reliable to indicate the
SERIRQ frame has been sent out because the EC always clears it
immediately. Unfortunately the SIRQRIS is always asserted in
continuous mode so that we cannot rely on it.

So, the udelay(4us) method is the best way we can use now.

Note: the quiet mode? Forget it. My EC never sends out further frames
      after the first has been sent.

BUG=none
TEST=on bds board.

Change-Id: Ica79b463f3dbe7435fe75f3db4cef00ad7ad5ec0
2012-02-03 12:38:42 +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
54f36995a4 stm32l: basic GPIO support
No interrupt support yet.

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

BUG=None
TEST=on Discovery EC console, using "gpioget" and "gpioset" commands
check we can switch the LED and read the button state.

Change-Id: I01294643d3df070a535dab5a6be02c296487fca5
2012-02-03 02:00:27 +00:00
David Hendricks
b2b6eb46b3 correct typo for STM32L GPIO bit set/reset register (BSSR --> BSRR))
Signed-off-by: David Hendricks <dhendrix@chromium.org>

BUG=none
TEST=none

Change-Id: I2f452e4f842ac3b67157f94c5e533b53d0d8baec
2012-02-02 17:44:30 -08:00
Vincent Palatin
71219213f5 Honor V=1 build flag when building tests recursively
Allow to display the verbose command lines even when building the test
programs.

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

BUG=None
TEST="make tests" with and without V=1

Change-Id: Ib1195c7e069d7823c2eb7b2311bd5f3c6cd6c835
2012-02-02 22:02:18 +00:00
Vincent Palatin
40528fe87f fix test compilation for STM32L
There is no host command yet and the "hello" test is not using it.

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

BUG=None
TEST=make tests BOARD=discovery && make tests BOARD=link

Change-Id: Ib7f49f8e38270a8c537e352396b1966abc801511
2012-02-02 22:02:06 +00:00
Vincent Palatin
d7fb7401c0 stm32l: update clock settings
Add a final wait to ensure the clock is ready before returning.
Setup the Flash according to the manual recommendations.

The low-speed oscillator and RTC are now done in the system module with
other RTC inits.

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

BUG=None
TEST=run the EC firmware on the Discovery and manually exercise various
path through the console.

Change-Id: I4e6149b6fd55c8fc72dbdf6bfc4a10665e0246bd
2012-02-02 22:02:06 +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
Vincent Palatin
77b154dd71 stm32l: implement reset cause and scratchpad
Allow to get proper reset reason.

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

BUG=None
TEST=On the discovery board, try the reset button, the "reboot" command
and a blocking wait, and see the proper reset reason displayed.
Initialize the scratchpad register with "setscratchpad" command and
check we can read it back after reboot.

Change-Id: I1fe1eec4987f7c9816454de4fd3b4addda4ad05a
2012-02-02 19:08:49 +00:00
Vincent Palatin
f771cca719 stm32l: add watchdog support
Use the Independant WatchDog.
The Window WatchDog would provide a nice early warning interrupt before
actually rebooting but the max period (128 ms) is probably too short for
our purpose.

The full GPIO support and the reboot cause detection will be implemented
in later steps.

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

BUG=None
TEST=on Discovery board, do blocking waits of 500ms and 1500ms, and
check the latter reboots the platform and the former does not.

Change-Id: I26e4d8b26b733269b7811cc3b3a09daf98ea364a
2012-02-02 17:05:40 +00:00
chrome-bot
a0d1a9e80e Merge "Fix a typo that cause compilation fail on BDS" 2012-02-02 05:39:05 -08:00
Vic Yang
35c6587bb5 Fix a typo that cause compilation fail on BDS
BUG=none
TEST=compile for BDS succeded.

Change-Id: I7790e2e5c2f2c9662a1c7b1fcf7a7442759a8653
2012-02-02 21:15:32 +08:00
Louis Yung-Chieh Lo
038b86ca8e Merge "Fix the missing IRQ problem." 2012-02-02 05:11:25 -08: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
b7f2a18859 Fix a bug that ADC input is not correctly configured.
The ADC input pin was always configured as BDS. Modified it to configure
the correct pin.

BUG=none
TEST=On Link, "rw 0x4002451C" show 0xff instead of 0xf7.

Change-Id: I1efd5cd59ad65f55cd673529afa6153add63ecac
2012-02-02 17:10:40 +08:00
chrome-bot
965987eeac Merge "Refactor ADC code and add Link charger current ADC support" 2012-02-01 18:55:58 -08:00
Vic Yang
1e5233a66d Refactor ADC code and add Link charger current ADC support
Refactor ADC code and move board/chip-specific part to corresponding
directories.
Implement function and console command to read Link charger current.

BUG=chrome-os-partner:7527
TEST=Read EC temperature and POT input on BDS.

Change-Id: I7fafd310ea49d9b2781f10c3453f5488da29a08a
2012-02-02 10:24:26 +08:00
Vincent Palatin
75b2bcf9b4 stm32l: add timer support
As the STM32L doesn't have any 32-bit timer, we use 2 chained 16-bit
counters to emulate a 32-bit one :
 * TIM2 is the MSB half-word (Slave timer)
 * TIM3 is the LSB half-word (Master time)

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

BUG=None
TEST=run timer_calib and timer_dos on the Discovery board, and check
waitms and gettime console functions against wall clock.

Change-Id: I8917207384d967fd87321797856e3d58b237f837
2012-02-01 22:49:22 +00:00
Vincent Palatin
6986ea134c stm32l: ensure we transmit as soon as characters are available
Force starting the transmission immediatly when ordered by the UART
buffering layer.

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

BUG=None
TEST=run EC console on Discovery and measure the timestamp of each
characters on the serial port.

Change-Id: I036a3fa0a60baa27de4ba0ceb386841a429535ac
2012-02-01 21:24:38 +00:00
Vincent Palatin
5d8e326da3 stm32l: avoid spurious USART interrupts
The TX empty interrupt needs an actual write to DR to be cleared.
So, we de-activate it before filling the TX buffer to ensure the
interrupt won't fire after the last write.

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

BUG=None
TEST=run EC console along with a lower priority task on Discovery board,
and check the task is scheduled as expected.

Change-Id: I56c33c6dd7ccfd238fd9d5910780d12945467010
2012-02-01 20:21:01 +00:00
chrome-bot
79dda3a44b Merge "Handle left and right arrow key in UART console." 2012-01-31 19:18:21 -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
Vincent Palatin
e3edad4459 stm32l: add UART driver
simple UART driver to get the serial console on the USART3.

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

BUG=None
TEST=run on Discovery board and check we get the first message on the
UART and the console is echoing the characters.

Change-Id: Id85999a5ddbd75804e9317a1b8c2fd4afb89eb38
2012-01-31 22:29:13 +00:00
Randall Spangler
df1d893322 Change COMx port to COM1
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7804
TEST=boot and check UART2 output; should have coreboot debug output

Change-Id: Ia0d16498180bb7b7d466d10268a959097e385fac
2012-01-30 16:11:44 -08:00
Vincent Palatin
5e22f8e51b expand properly the IRQ number for IRQ declaration macro
Expand the macros before building the priority variable name in order to
ensure we have a valid name.

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

BUG=None
TEST=check manually preprocessor expansion for several combinations.

Change-Id: I926821d42c966ac674e7d24254c9f22779f93ca2
2012-01-30 22:32:39 +00:00
Vincent Palatin
fb52ad00e4 stm32l: initialize clocks
Run from internal clock at 16Mhz, but enable PLL to get a better
precision.

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

BUG=None
TEST=run on discovery board and check software is still alive after
clock initialization.

Change-Id: I8425482825015adf96c30e67a9320d0df2f4f2b7
2012-01-30 22:32:39 +00:00
Vincent Palatin
4c98732ce7 Add register definitions for STM32L SoC
Define IRQs and register addresses for basic peripherals to do STM32L
bringup.

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

BUG=None
TEST=mostly untested, there should be typos over there...

Change-Id: Ib6d90436e25be74f724112619cdae7acccfaf085
2012-01-30 22:32:38 +00:00
Randall Spangler
861db4c6f3 Add workaround for fan controller to handle speeds more than 7000 rpm
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7718
TEST=manual

// enable fan
gpioset enable_vs 1
// set fan speed to 7000
fanset 7000
faninfo
// should report duty cycle about 65%, fan speed about 7000 rpm, status = 2
fanset 4000
faninfo
// should report duty cycle about 25%, fan speed about 4000 rpm, status = 2
fanset -1
// should report duty cycle 100%, fan speed about 8800 rpm, status = 3

Change-Id: Ib7d7df14ad240811e6e79bc1fc4ecf0e6841c334
2012-01-27 16:06:15 -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
Randall Spangler
7a5832bcd8 Fix setting GPIO outputs and keyboard scanning
Keyboard scanning was not properly configuring GPIOs on link.  Among
the problems, it was setting GPIO level then direction, when it needs
to set direction first.  Also fixed this in gpio pre-init.

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

BUG=chrome-os-partner:7761
TEST=1) press keys on keyboard; see keyboard state change on console
2) 'gpioget PCH_PWRBTNn' should report 1 after boot, not 0

Change-Id: I54010aa6eef1de4822574f964de369b459ee6d0f
2012-01-27 11:18:03 -08:00
Vincent Palatin
414499778d add the skeleton for STM32L chip and discovery board
All hardware drivers code is stubbed excepted a few configuration
settings.

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

BUG=None
TEST=make BOARD=discovery

Change-Id: Ic9e88a0f51ab626679c8aeb6192272e66a3f79b8
2012-01-26 16:50:55 -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
Randall Spangler
c5da68d224 Add i2cread command
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=from console, do 'charger' then 'i2cread 1 0x12 2'; should print 0x00 0x10

Change-Id: I70947e2c5ddc267afd6752add838ee5280f1fbfd
2012-01-26 15:56:06 -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
Randall Spangler
c4a867984e Fix missing GPIO interrupts
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=push and release power button; should see debug messages

Change-Id: I4a08b56247baa85555514623db7a04ab4638ca0e
2012-01-26 13:39:36 -08:00
Randall Spangler
028150a059 Increase link image size to 40KB
with x86 power module enabled, it no longer fits in 32KB.

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

BUG=none
TEST=make

Change-Id: I38c9054efd8a072cc5800cc87936e53e2df00e58
2012-01-26 13:36:07 -08:00
Vincent Palatin
09b937b767 Ensure the panic UART is set to the right UART
Preparatory work to introduce a second SoC : 2nd series 4/4

Add a build time assertion which checks whether the UART used in the C
uart code is the same one as the one defined for assembly panic code.

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

BUG=None
TEST=build for BDS with both good and bad address in CONFIG_UART_ADDRESS

Change-Id: I28dd6089bc938f06be0654d7bed75d7d698fafe0
2012-01-26 01:55:37 +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
4cca2932ef Move SoC-independant headers to another directory
Preparatory work to introduce a second SoC : 2nd series 1/4

The atomic operations are SoC independant since they are only using
LDREX/STREX instructions which are just core specific ARMv7-M).

The watchdog header defines the API which is common to all platforms.

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

BUG=None
TEST=run EC firmware on BDS and check a few console commands
2012-01-26 01:29:48 +00:00
Vincent Palatin
9a465855f8 NVIC registers are not SoC specific
Preparatory work to introduce a second SoC : 5/5

All Cortex-M3/4 have the same NVIC registers at the same address.

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

BUG=None
TEST=run EC firmware on BDS and check a few console commands

Change-Id: I6b03c4c1fb21850be8c8afb711ea44134c8cdea1
2012-01-25 22:50:07 +00:00
Vincent Palatin
9301cef981 Add configuration parameters for the panic UART code
Preparatory work to introduce a second SoC : 4/5

Allow to use the common code for most SoC.
Also simplify the UART code, we don't need speed on the panic path.

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

BUG=None
TEST=trigger a panic and check the UART output on BDS

Change-Id: I11f7bbc571ab9efbc21fb7b805bf4e271b192c3b
2012-01-25 22:50:07 +00:00
Vincent Palatin
cf9fcef328 Move OS files to a CPU specific directory
Preparatory work to introduce a second SoC : 3/5

We split the drivers files which contain SoC specific drivers from the
OS files which only depend the actual CPU core.

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

BUG=None
TEST=run EC firmware on BDS and test a few commands on the console.

Change-Id: I598f8b23e074da9bd6b0e2ce6689c1075fe854f0
2012-01-25 22:50:07 +00:00
Vincent Palatin
645dad5d3f Split the timer code between OS code and hardware dependant code.
Preparatory work to introduce a second SoC : 2/5

The hwtimer.* files implement the driver for the SoC timer block.
The timer.* files provides the OS level clock/timer functions.

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

BUG=None
TEST=on BDS, check 'waitms' and 'gettime' on the EC console.

Change-Id: Icbc58d9be59ee268e2d5a94f8b20de0cabcdc91d
2012-01-25 22:50:07 +00:00