Files
OpenCellular/include/button.h
Aseda Aboagye 34a97f50d5 buttons: Make buttons[] common.
Nearly every board had a buttons array defined in which its contents had
the standard volume buttons.  This commit creates a single common
buttons array that can contain the standard volume buttons and recovery
buttons.  If a board has volume up and down buttons, they can simply
define CONFIG_VOLUME_BUTTONS and it will populate the buttons array with
the standard definition.  The buttons are active low and have a 30 ms
debounce period.  Similiarly, if a board has a dedicated recovery
button, defining CONFIG_DEDICATED_RECOVERY_BUTTON will also populate the
buttons array with a recovery button.

BUG=chromium:783371
BRANCH=None
TEST=make -j buildall.
TEST=Flash a device with CONFIG_VOLUME_BUTTONS, verify pressing volume
buttons still work.

Change-Id: Ie5d63670ca4c6b146ec8ffb64d40ea9ce437b913
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/773794
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-17 20:18:38 -08:00

74 lines
1.6 KiB
C

/* Copyright (c) 2014 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.
*/
/* Button API for Chrome EC */
#ifndef __CROS_EC_BUTTON_H
#define __CROS_EC_BUTTON_H
#include "common.h"
#include "gpio.h"
#define BUTTON_FLAG_ACTIVE_HIGH (1 << 0)
enum keyboard_button_type {
KEYBOARD_BUTTON_POWER = 0,
KEYBOARD_BUTTON_VOLUME_DOWN,
KEYBOARD_BUTTON_VOLUME_UP,
KEYBOARD_BUTTON_RECOVERY,
KEYBOARD_BUTTON_CAPSENSE_1,
KEYBOARD_BUTTON_CAPSENSE_2,
KEYBOARD_BUTTON_CAPSENSE_3,
KEYBOARD_BUTTON_CAPSENSE_4,
KEYBOARD_BUTTON_CAPSENSE_5,
KEYBOARD_BUTTON_CAPSENSE_6,
KEYBOARD_BUTTON_CAPSENSE_7,
KEYBOARD_BUTTON_CAPSENSE_8,
KEYBOARD_BUTTON_COUNT
};
struct button_config {
const char *name;
enum keyboard_button_type type;
enum gpio_signal gpio;
uint32_t debounce_us;
int flags;
};
enum button {
#ifdef CONFIG_VOLUME_BUTTONS
BUTTON_VOLUME_UP,
BUTTON_VOLUME_DOWN,
#endif /* defined(CONFIG_VOLUME_BUTTONS) */
#ifdef CONFIG_DEDICATED_RECOVERY_BUTTON
BUTTON_RECOVERY,
#endif /* defined(CONFIG_DEDICATED_RECOVERY_BUTTON) */
BUTTON_COUNT,
};
/* Table of buttons for the board. */
extern const struct button_config buttons[];
/*
* Buttons used to decide whether recovery is requested or not
*/
extern const struct button_config *recovery_buttons[];
extern const int recovery_buttons_count;
/*
* Button initialization, called from main.
*/
void button_init(void);
/*
* Interrupt handler for button.
*
* @param signal Signal which triggered the interrupt.
*/
void button_interrupt(enum gpio_signal signal);
#endif /* __CROS_EC_BUTTON_H */