Files
OpenCellular/include/keyboard_raw.h
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

75 lines
1.9 KiB
C

/* Copyright (c) 2013 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.
*
* Raw access to keyboard GPIOs.
*
* The keyboard matrix is read by driving output signals on the column lines
* and reading the row lines.
*/
#ifndef __CROS_EC_KEYBOARD_RAW_H
#define __CROS_EC_KEYBOARD_RAW_H
#include "common.h"
#include "gpio.h"
/* Column values for keyboard_raw_drive_column() */
enum keyboard_column_index {
KEYBOARD_COLUMN_ALL = -2, /* Drive all columns */
KEYBOARD_COLUMN_NONE = -1, /* Drive no columns (tri-state all) */
/* 0 ~ KEYBOARD_COLS-1 for the corresponding column */
};
/**
* Initialize the raw keyboard interface.
*
* Must be called before any other functions in this interface.
*/
void keyboard_raw_init(void);
/**
* Finish intitialization after task scheduling has started.
*
* Call from the keyboard scan task.
*/
void keyboard_raw_task_start(void);
/**
* Drive the specified column low.
*
* Other columns are tristated. See enum keyboard_column_index for special
* values for <col>.
*/
void keyboard_raw_drive_column(int col);
/**
* Read raw row state.
*
* Bits are 1 if signal is present, 0 if not present.
*/
int keyboard_raw_read_rows(void);
/**
* Enable or disable keyboard interrupts.
*
* Enabling interrupts will clear any pending interrupt bits. To avoid missing
* any interrupts that occur between the end of scanning and then, you should
* call keyboard_raw_read_rows() after this. If it returns non-zero, disable
* interrupts and go back to polling mode instead of waiting for an interrupt.
*/
void keyboard_raw_enable_interrupt(int enable);
#ifdef HAS_TASK_KEYSCAN
/**
* GPIO interrupt for raw keyboard input
*/
void keyboard_raw_gpio_interrupt(enum gpio_signal signal);
#else
static inline void keyboard_raw_gpio_interrupt(enum gpio_signal signal) { }
#endif /* !HAS_TASK_KEYSCAN */
#endif /* __CROS_EC_KEYBOARD_RAW_H */