mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
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>
104 lines
2.8 KiB
C
104 lines
2.8 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/*
|
|
* Chipset module for Chrome EC.
|
|
*
|
|
* This is intended to be a platform/chipset-neutral interface, implemented by
|
|
* all main chipsets (x86, gaia, etc.).
|
|
*/
|
|
|
|
#ifndef __CROS_EC_CHIPSET_H
|
|
#define __CROS_EC_CHIPSET_H
|
|
|
|
#include "common.h"
|
|
#include "gpio.h"
|
|
|
|
/*
|
|
* Chipset state mask
|
|
*
|
|
* Note that this is a non-exhaustive list of states which the main chipset can
|
|
* be in, and is potentially one-to-many for real, underlying chipset states.
|
|
* That's why chipset_in_state() asks "Is the chipset in something
|
|
* approximating this state?" and not "Tell me what state the chipset is in and
|
|
* I'll compare it myself with the state(s) I want."
|
|
*/
|
|
enum chipset_state_mask {
|
|
CHIPSET_STATE_HARD_OFF = 0x01, /* Hard off (G3) */
|
|
CHIPSET_STATE_SOFT_OFF = 0x02, /* Soft off (S5) */
|
|
CHIPSET_STATE_SUSPEND = 0x04, /* Suspend (S3) */
|
|
CHIPSET_STATE_ON = 0x08, /* On (S0) */
|
|
/* Common combinations */
|
|
CHIPSET_STATE_ANY_OFF = (CHIPSET_STATE_HARD_OFF |
|
|
CHIPSET_STATE_SOFT_OFF), /* Any off state */
|
|
};
|
|
|
|
#ifdef HAS_TASK_CHIPSET
|
|
|
|
/**
|
|
* Check if chipset is in a given state.
|
|
*
|
|
* @param state_mask Combination of one or more CHIPSET_STATE_* flags.
|
|
*
|
|
* @return non-zero if the chipset is in one of the states specified in the
|
|
* mask.
|
|
*/
|
|
int chipset_in_state(int state_mask);
|
|
|
|
/**
|
|
* Ask the chipset to exit the hard off state.
|
|
*
|
|
* Does nothing if the chipset has already left the state, or was not in the
|
|
* state to begin with.
|
|
*/
|
|
void chipset_exit_hard_off(void);
|
|
|
|
/* This is a private chipset-specific implementation for use only by
|
|
* throttle_ap() . Don't call this directly!
|
|
*/
|
|
void chipset_throttle_cpu(int throttle);
|
|
|
|
/**
|
|
* Immediately shut off power to main processor and chipset.
|
|
*
|
|
* This is intended for use when the system is too hot or battery power is
|
|
* critical.
|
|
*/
|
|
void chipset_force_shutdown(void);
|
|
|
|
/**
|
|
* Reset the CPU and/or chipset.
|
|
*
|
|
* @param cold_reset If !=0, force a cold reset of the CPU and chipset;
|
|
* if 0, just pulse the reset line to the CPU.
|
|
*/
|
|
void chipset_reset(int cold_reset);
|
|
|
|
/**
|
|
* Interrupt handler to power GPIO inputs.
|
|
*/
|
|
void power_interrupt(enum gpio_signal signal);
|
|
|
|
#else /* !HAS_TASK_CHIPSET */
|
|
/*
|
|
* Allow other modules to compile if the chipset module is disabled. This is
|
|
* commonly done during early stages of board bringup.
|
|
*/
|
|
|
|
static inline int chipset_in_state(int state_mask)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void chipset_exit_hard_off(void) { }
|
|
static inline void chipset_throttle_cpu(int throttle) { }
|
|
static inline void chipset_force_shutdown(void) { }
|
|
static inline void chipset_reset(int cold_reset) { }
|
|
static inline void power_interrupt(enum gpio_signal signal) { }
|
|
|
|
#endif /* !HAS_TASK_CHIPSET */
|
|
|
|
#endif /* __CROS_EC_CHIPSET_H */
|