Commit Graph

43 Commits

Author SHA1 Message Date
Shawn Nematbakhsh
5b93f04c19 mec1322: Allow GPIO hibernate state to be specified at board-level
Add a new board-level function board_get_gpio_hibernate_state which can
optionally be defined to set the desired state of a GPIO during
hibernate.

BUG=chrome-os-partner:43807
TEST=Manual on Glados with subsequent commit. Run 'hibernate' on console,
verify that LED remains off. Press power button, verify that board wakes.
BRANCH=None

Change-Id: Ica11554e231e88773c3e139fea4622377ebe1e42
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/292471
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-11 21:21:28 +00:00
li feng
1c7baaf71f I2C: i2c_raw_mode() should only touch I2C port specified
After I2C unwedge, *all* I2C ports will be re-initialized in
i2c_raw_mode() by gpio_config_module(MODULE_I2C, 1);
This means *all* I2C pins will be programmed as	GPIO then enable I2C
alternate function.

If I2C Unwedge happened while there is an active I2C transacation on
another port, the active I2C transaction will be corrupted, since the
pins will be temporary programmed as GPIO Output High.

BUG=chrome-os-partner:40519
TEST=Warm-reboot test on Cyan EVT and no discharging while AC is on.
BRANCH=none

Change-Id: I3be1d5c60bf4ab385bc077202406ec7abd8b2add
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/287493
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Denny Iriawan <denny.iriawan@intel.com>
2015-07-25 14:49:31 +00:00
Shawn Nematbakhsh
1f7ab338b1 cleanup: GPIO: Use common macro for converting mask to GPIO
The same calculation is used across the code, so move it to a common
macro.

BUG=chrome-os-partner:42104
TEST=Verify Glados still boots AP.
BRANCH=None

Change-Id: I90da348f37fc670971737cfc5ddcfb9c34096c4b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/286169
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-07-19 20:38:37 +00:00
Dino Li
e881d99fde it8380dev: add pin 3.3v/1.8v selection
add GPIO_SEL_1P8V flag for 1.8v/3.3v selection.

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=1. To configure 1.8V/3.3V pin to 1.8V,
        set GPIO_SEL_1P8V flag in gpio.inc.
     2. The corresponding bit will be set as default value if the pin
        is not listed in gpio.inc.

Change-Id: Ica02aabe40b83fcb4d33bd28d717a0633bdef5f3
Reviewed-on: https://chromium-review.googlesource.com/281842
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
2015-06-30 17:18:54 +00:00
Bill Richardson
313623afee cleanup: Don't shadow NULL with an enum
For the few platforms without gpio.inc, use this

  enum gpio_signal {
     GPIO_COUNT
  };

instead of this

  enum gpio_signal {
     NULL
  };

The only reason this worked at all is that the headers are
included in a particular order.

BUG=none
BRANCH=none
TEST=make buildall

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I81533f3614d0b4c7389f9edd42cd8ac018581f46
Reviewed-on: https://chromium-review.googlesource.com/278120
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-06-18 09:23:07 +00:00
Aseda Aboagye
e9883124ff gpio: Refactor IRQ handler pointer out of gpio_list
In the gpio_info struct, we had a irq_handler pointer defined even
though a majority of the GPIOs did not have irq handlers associated. By
removing the irq_handler pointer out of the struct, we can save some
space with some targets saving more than others. (For example, ~260
bytes for samus_pd).

This change also brings about a new define:

     GPIO_INT(name, port, pin, flags, signal)

And the existing GPIO macro has had the signal parameter removed since
they were just NULL.

     GPIO(name, port, pin, flags)

In each of the gpio.inc files, all the GPIOs with irq handlers must be
defined at the top of the file. This is because their enum values from
gpio_signal are used as the index to the gpio_irq_handlers table.

BUG=chromium:471331
BRANCH=none
TEST=Flashed ec to samus and samus_pd, verified lightbar tap, lid, power
button, keyboard, charging, all still working.
TEST=Moved a GPIO_INT declaration after a GPIO declaration and watched the build
fail.
TEST=make -j BOARD=peppy tests
TEST=make -j BOARD=auron tests
TEST=make -j BOARD=link tests

Change-Id: Id6e261b0a3cd63223ca92f2e96a80c95e85cdefb
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/263973
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-04-10 22:08:25 +00:00
Bill Richardson
02013f6aa3 cr50: Separate ARM core GPIOs from pinmux configuration
This separates the configuration of the ARM core GPIOs from the
routing of internal peripherals to external pins. Both are still
described in the gpio.inc file, but are less dependent on each
other.

BUG=chrome-os-partner:33818
BRANCH=none
TEST=manual

Before this CL, running "sysjump rw" or trying to use more than 8
GPIOs caused hangs and reboots. Now it doesn't.

Change-Id: If962a7c5ad4136837b2ea00ae016a440f07d7e23
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251015
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-02-20 03:00:04 +00:00
Bill Richardson
b4274d04f3 cleanup: bitmasks should be unsigned values
Change the struct gpio_info to use uint32_t for the mask field,
instead of signed integer.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I8cc7e3d06a00bd3c890522a896e36e1eb18a862e
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251013
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-02-20 02:59:57 +00:00
Myles Watson
221e5ca878 Add support for shared interrupts.
The nRF51 chips from Nordic have shared interrupts.

Having a flag for that makes it easier to implement.

BUG=chrome-os-partner:34477
BRANCH=none
TEST=make buildall -j

Signed-off-by: Myles Watson <mylesgw@chromium.org>

Change-Id: I89c78ace99085c359db8515667eaffb5617f0162
Reviewed-on: https://chromium-review.googlesource.com/234390
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Myles Watson <mylesgw@chromium.org>
Tested-by: Myles Watson <mylesgw@chromium.org>
2014-12-19 00:05:16 +00:00
Vincent Palatin
1b1c3089af g: implement GPIOs
Add a driver for the GPIO controller.

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

BRANCH=none
BUG=chrome-os-partner:33816
TEST=press the push buttons on the board and see the console text
message and the LEDs lighting up.

Change-Id: Idb408fe1c341beb8a97f2047ba6740e0d40cedf5
Reviewed-on: https://chromium-review.googlesource.com/233307
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-12-10 22:14:07 +00:00
Anton Staaf
1e73a1ba06 GPIO: Reduce code duplication in STM32 gpio driver
Previously the F0 and L variants had almost identical driver files
and the F variant shared about half of its driver.  This refactor
moves the shared code into gpio.c and gpio-f0-l.c, the latter
is for code shared between the F0 and L variants.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=none
TEST=make buildall -j
     Followed by manual testing of interrupt on change and UART
     functionality on STM32F0 based discovery board.

Change-Id: I920babd1861548272af2857c8bd3e4f9dac4985c
Reviewed-on: https://chromium-review.googlesource.com/207986
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-07-17 00:39:47 +00:00
Anton Staaf
9ccfd4553e gpio: Replace duplication in gpio declarations with X-macro file
Previously each board.h and board.c contained an enum and an array
for gpio definitons that had to be manually kept in sync, with no
compiler assistance other than that their lengths matched.

This change adds a single gpio.inc file that declares all gpio's
that a board uses and is used as an X-macro include file to
generate both the gpio_signal enum and the gpio_list array.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=none
TEST=make buildall -j

Change-Id: If9c9feca968619a59ff9f20701359bcb9374e4da
Reviewed-on: https://chromium-review.googlesource.com/205354
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-06-26 02:43:01 +00:00
Randall Spangler
7f3ed512db gpio: Make GPIO_INT_BOTH explicitly RISING|FALLING
For historical reasons on LM4, we defined GPIO_INT_F_BOTH separately
from GPIO_INT_F_RISING and GPIO_INT_F_FALLING.  This means that the
code has weird checks like BOTH || (RISING && FALLING), which have
propagated in error-prone ways across the other chips.

Instead, explcitly define BOTH to be RISING|FALLING.

Ideally, we would have called it GPIO_INT_EDGE to match
GPIO_INT_LEVEL, but changing that now would be a big find-replace.
Which might still be a good idea, but that is best done in its own CL.

BUG=chrome-os-partner:24204
BRANCH=none
TEST=build and boot pit, spring, and link; that covers STM32F, STM32L, and LM4.

Change-Id: I23ba05a3f41bb14b09af61dc52a178f710f5c1bb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/177643
Reviewed-by: Jeremy Thorpe <jeremyt@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-11-23 05:11:31 +00:00
Vic (Chun-Ju) Yang
14c7191b53 mec1322: initial commit
This is the initial commit of mec1322 support. This includes:
  - Basic GPIO driver. Interrupt not supported yet.
  - Microsecond timer
  - UART driver

The script to pack the firmware binary will be checked in in
following-up CL.

BUG=chrome-os-partner:24107
TEST=Build and boot on eval board
BRANCH=None

Change-Id: I9013c908049d1f740f84bb56abca51b779f39eef
Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/175716
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-11-21 04:30:55 +00:00
Alec Berg
10bd1db6d7 lm4: Use low speed clock in deep sleep.
Changed the low power idle task to use the low speed clock in deep
sleep. The low power idle task is currently only enabled for Peppy,
Slippy, and Falco. This change decreases power consumption when
the AP is not running.

Note that the low speed clock is slow enough that the JTAG cannot be
used and the EC console UART cannot be used. To work around that,
this commit detects when the JTAG is in use and when the EC console
is in use, and will not use the low speed clock if either is in use.
The JTAG in use never clears after being set and the console in use
clears after a fixed timeout period.

BUG=None
BRANCH=None
TEST=Passes all unit tests.
Tested that the EC console works when in deep sleep.
Tested that it is possible to run flash_ec when in deep sleep and
using the low speed clock.

Change-Id: Ia65997eb8e607a5df9b2c7d68e4826bfb1e0194c
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173326
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-10-21 23:59:38 +00:00
Alec Berg
27e063ea10 lm4: Modified clock gating to allow easy expansion to low power.
Created a new function to enable or disable clocks to various
peripherals. This new function makes it easy to specify if you
want the clock enabled in run mode, sleep mode, and/or deep
sleep mode.

Added infrastructure to specify which GPIOs should interrupt the
EC from deep sleep.

BUG=none
BRANCH=none
TEST=Passes all unit tests. Ran on a peppy and verified that
the clock gate control registers in run mode (LM4_RCGC regs)
were the same before and after this change.

Change-Id: Ia5009ac8c837f61dca52fe86ebdeede2e1a7fe4d
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/172454
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-10-10 23:14:20 +00:00
Vic Yang
eff7a1910a Support multi-bit mask in STM32L's GPIO functions
The definition of GPIO interface allows passing in multi-bit mask, and
this is what's done by gpio_config_module(). Fix STM32L's function so
that it doesn't accidentally set incorrect GPIO register values.

BUG=chrome-os-partner:22605
TEST=On Kirby, do 'led r 0' and check the value of 0x40020800 is
0x01540000.
BRANCH=None

Change-Id: I9a1c8074aab7345485a590ecf138bf99d0742997
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168739
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2013-09-11 19:45:38 +00:00
Vic Yang
2270f2bb03 Fix a bug that GPIO cannot be set as input on stm32l
GPIO_INPUT is defined as 0, and any GPIO flag cannot be examined against
GPIO_INPUT. Change GPIO_INPUT to non-zero value to avoid this.

BUG=chrome-os-partner:22275
TEST=On Kirby, set a GPIO to output and pull it low, and then set it back to
input. Check it can be pull high externally.
TEST=Build all boards.
TEST=Boot link and spring.
BRANCH=None (unless this bug hits some other boards.)

Change-Id: I84b9936c24af538ac59c36129fda27ca879bf9d1
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167190
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-04 05:45:52 +00:00
Randall Spangler
f2b56fcb9f Clean up configuring GPIO alternate functions
GPIO alternate functions used to be configured throughout the code,
which made it hard to tell which ones you needed to configure yourself
in board.c.  It also sometimes (chip/lm4/i2c.c) led to GPIOs being
configured as alternate functions even if they weren't used on a given
board.

With this change, every board has a table in board.c which lists ALL
GPIOs which have alternate functions.  This is now the only place
where alternate functions are configured.  Each module then calls
gpio_init_module() to set up its GPIOs.

This also fixes a bug where gpio_set_flags() ignored most of the flags
passed to it (only direction and level were actually used).

On stm32f, gpio_set_alternate() does not exist, and pins are
configured via direct register writes from board.c.  Rather than
attempt to change that in the same CL, I've stubbed out
gpio_set_alternate() for stm32f, and will fix the register writes in a
follow-up CL.

BUG=chrome-os-partner:21618
BRANCH=peppy (fixes I2C1 being initialized even though those pins are used
       for other things)
TEST=boot link, falco, pit, spring

Change-Id: I40f47025d8f767e0723c6b40c80413af9ba8deba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64400
2013-08-07 12:43:35 -07:00
Bill Richardson
af77729737 Add build-time checks on board-specific array sizes.
We've been declaring a bunch of statically-sized arrays:

  extern struct foo_t foo[FOO_COUNT];

And then initializing them like so:

  struct foo_t foo[FOO_COUNT] = {
    /* blah */
  };

That only catches cases where we initialize with too many entries. It
doesn't catch cases where we haven't initialized enough. This change tests
for both cases like so:

  extern struct foo_t foo[];

  struct foo_t foo[] = {
    /* blah */
  };
  BUILD_ASSERT(ARRAY_SIZE(foo) == FOO_COUNT);

The affected arrays are:

  adc_channels[ADC_CH_COUNT]
  gpio_list[GPIO_COUNT]
  temp_sensors[TEMP_SENSOR_COUNT]
  x86_signal_list[X86_SIGNAL_COUNT]
  i2c_ports[I2C_PORTS_USED]

BUG=chrome-os-partner:18343
BRANCH=falco,peppy
TEST=build all platforms

All platforms should still build, all tests should still pass.

Change-Id: Ibb16dc3201f32df7cdc875648e89ba4ffb09f733
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63833
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-31 12:33:31 -07:00
Bill Richardson
1695760e95 Rename GPIO_HI_Z macros to more descriptive GPIO_ODR_HIGH/LOW
GPIO_HI_Z was a bit misleading (it's high impedance by default, but it's
actually an output not an input), but when we added GPIO_HI_Z_OPEN to mean
"open-drain output, pulled low by default", it got too confusing.

This renames those macros to:

  #define GPIO_ODR_HIGH    (GPIO_OUTPUT | GPIO_OPEN_DRAIN | GPIO_HIGH)
  #define GPIO_ODR_LOW     (GPIO_OUTPUT | GPIO_OPEN_DRAIN | GPIO_LOW)

BUG=chrome-os-partner:18788
BRANCH=none
TEST=none

No functional change, just renaming some macros. If it compiles, it should
be unchanged in behavior.

Change-Id: Ic84d7be8531f2b240a8eca4f6cfe5291ebd2d5ef
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58596
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2013-06-13 18:13:23 -07:00
Aaron Durbin
3ca68b3134 haswell: fix RCIN# GPIO setting
The gpio pin used for RCIN# should be configured as open drain as the
rail is pulled up by a non-EC rail. Driving it high would leak power.
The current GPIO_HI_Z macro uses GPIO_HIGH as the default state.
However, it has been found that this actually drives the pin to ground.
It is still unclear how Link works or doesn't.

BUG=chrome-os-partner:19355
BRANCH=none
TEST=manual: boot on slippy without RCIN# causing reset and
     the 'apreset warm' EC command works as expected.

Change-Id: I71425075f8d77b3d7e576a59fc24f823790e2655
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56269
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2013-05-22 12:29:11 -07:00
Randall Spangler
108235225d Refactor gpio_set_level() and gpio_pre_init()
gpio_set_level() now allows setting the pin level if GPIO_LOW or
GPIO_HIGH is specified.  Previously, stm32 platforms did this even
though the definition of gpio_set_level() said it wouldn't work.

Fixed gpio_set_level() not setting level after warm reboot on stm32
because it was checking the GPIO_DEFAULT flag in the wrong place.

Fixed LM4 still mucking with alternate function settings and levels
even if GPIO_DEFAULT was specified.

And checked gpio_list[] and all of the calls to gpio_set_flags() to
make sure everything still behaves the same way it did before (or
better, in the case of actual bugs).

BUG=chrome-os-partner:18718
BRANCH=none
TEST=build all platforms; boot spring and link

Change-Id: I4b84815f76060252df235ff9a37da52c54a8eac5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48058
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-15 14:27:45 -07:00
Randall Spangler
79c6132a6e Allow GPIO alternate function 0
gpio_set_alternate_function() used 0 to mean "normal GPIO function".
But on chips like STM32L, alternate function 0 is actually a function
on some pins.  So change "normal GPIO function" to -1.

Also add support for this on STM32L.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build and boot link and daisy

Change-Id: I9cdd9ad91a315b616e373a0dc9a50545cf9d20fa
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47903
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-11 15:38:09 -07:00
Randall Spangler
447b05b828 Move asserting host keyboard interrupt signal to keyboard_scan
The implementation is identical on all stm32 hardware, so remove all
the duplicate copies from board.c files.  mccrosskey doesn't have
GPIO_EC_INT so stub it out like we do on bds.

No functional change, just moving code.

BUG=none
BRANCH=none
TEST=build mccrosskey,daisy,snow,spring

Change-Id: I7d4378650d7b4c640c15180c41459a41620f5bd3
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45920
2013-03-20 17:42:04 -07:00
Randall Spangler
ef89439cc0 Clean up GPIO module.
No functional changes, just code cleanup.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=gpioget returns reasonable values

Change-Id: I4301ccc68ade775f78f4ccd84710d2cd4bc25252
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36800
2012-10-30 12:42:46 -07:00
Randall Spangler
2957c3cf8b Clean up GPIO module
Just code cleanup; no functional changes

BUG=chrome-os-partner:15579
BRANCH=none
TEST=build code; boot link; gpioget still works

Change-Id: If0770c1a5ce0d5c51ba528fbe2944a73fafa949b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36556
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-25 11:24:02 -07:00
Simon Glass
130531ab8c Allow GPIOs to be set up later
At present GPIOs must be staticly defined in a table. This is efficient
but inflexible, and requires error-prone and correponding #ifdefs both
in the board's gpio.h and gpio.c files.

Create a GPIO_UNSET option for GPIOs. This allows them to be assigned
an enum value, but have the actual use under program control.

BUG=chrome-os-partner:13064
BRANCH=snow,link
TEST=manual
build and boot on snow with later changes. See the AC power GPIO does
not change when un/plugging power.

Change-Id: Iab58275923d7d6cfce62c890b5db9b6758279a4c
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/31302
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-08-27 12:16:10 -07:00
Simon Glass
aa64550a3f gpio: Add fast access to GPIO level
The current gpio_get_level() is pretty slow because it looks things up each
time. Add a new function to find out the register address and mask to use
to check the value for a particular GPIO.

Time-critical code can then use this to check a GPIO.

BUG=chrome-os-partner:10146
TEST=manual:
build and boot on snow;
Power on the board, hold power button for 10s and see that it powers off
Power control still works, thus GPIOs are functional

Change-Id: Ifc6c56f5cb811e0243e7712725a51948eabd42ab
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26175
2012-07-02 22:35:52 -07:00
Randall Spangler
8ea7983c29 Add gpio_set_flags() and system_get_board_version()
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:9117
TEST=version; board version should be 0 on proto1 and 1 on EVT

Change-Id: Ic64ad0d009151fbda09f5c1605ef50ae708cb6ae
2012-05-08 21:00:38 -07:00
Simon Glass
42842e4378 Move gpio list into gpio.h header file
This is referenced by various files, so should be in the gpio.h header.

BUG=none
TEST=manual:
build and boot on daisy, see that USB download still works
build on all platforms

Change-Id: If579c975ef6c82988b9e411eeaa97c950d9efce4
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-05-08 11:31:52 -07:00
Simon Glass
ea845714fd Add gpio_get_name() to return the name of a signal
Add this to the GPIO API. It seems that the implementation is copied
in LM4 and STM32 so I have reluctantly done the same with this new
function.

BUG=chrome-os-partner:9424
TEST=build and boot on Daisy

Change-Id: Ifddc52e69b2b33af2645384c0171dd264e588fcd
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-05-03 22:05:57 -07:00
Randall Spangler
f4e772708b Added HOOK_INIT for driver module inits
This covers modules which need to initialize before task_start(), but
don't particularly care in what order they're initialized.

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

BUG=none
TEST=if it boots, it works

Change-Id: I69829aac8d1c3c14ee04916a794b84bbf03a09eb
2012-04-19 13:08:58 -07:00
David Hendricks
28292ae663 add more explicit GPIO types
This patch adds explicit handling of open-drain outputs
and adds Hi-Z for high-impedence state (floating) outputs.

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

BUG=none
TEST=compile tested

Change-Id: I1a0c2e8366f6a82cd9cd7e83e57122944f2bdc2d
2012-04-13 14:46:33 -07:00
Randall Spangler
ff3ebed7a8 GPIO interrupts are disabled by default
Added gpio_enable_interrupt() to enable them.  This ensures that a
module which handles GPIO interrupts doesn't get them until it's
ready.

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

BUG=chrome-os-partner:7456
TEST=toggle power button while rebooting; without this fix it triggers a hard fault.

Change-Id: I35d926053963a70dd9246ce46a4913603b2b2489
2012-01-13 10:34:09 -08:00
Randall Spangler
3c90a7f2ac Move board-specific GPIO lists to board-specific files
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

Change-Id: I47fd5d709a9575e41fdcdf21a7440ebbb762cef5
2012-01-12 16:47:46 -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
a8afa116be Tidy GPIO configuration and board-specific configs for modules.
Signed-off-by: Randall Spangler <rspangler@chromium.org>

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

Change-Id: Ia06707db78ea9a9313b49a93e8732a7fc9fcc191
2012-01-12 13:11:57 -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
a767d9b22b Add GPIO get/set commands
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7528
TEST=from debug console,

gpioget --> prints current level.  Run a few times to see DEBUG_LED
value toggle.

gpioset debug_led 1 --> turns debug LED on.  Run repeatedly to
override the idle task toggling it off.

Change-Id: I7c64044228697e052a9c20eb052d37a1f640f6e7
2012-01-11 10:59:59 -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
Randall Spangler
bdf7da5b08 Initial sources import 1/3
source files mainly done by Randall.

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

Change-Id: Iaff83a842b17f3350fb6f2a3f1597ad4c29bd12a
2011-12-07 19:10:02 +00:00