mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
f3f837e52b
This adds some sysfs entries to provide userspace control of the four-element LED "lightbar" on the Chromebook Pixel. This only instantiates the lightbar controls if the device actually exists. To prevent DoS attacks, this interface is limited to 20 accesses/second, although that rate can be adjusted by a privileged user. On Chromebooks without a lightbar, this should have no effect. On the Chromebook Pixel, you should be able to do things like this: $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar $ echo 0x80 > brightness $ echo 255 > brightness $ $ cat sequence S0 $ echo konami > sequence $ cat sequence KONAMI $ $ cat sequence S0 And $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar $ echo stop > sequence $ echo "4 255 255 255" > led_rgb $ echo "0 255 0 0 1 0 255 0 2 0 0 255 3 255 255 0" > led_rgb $ echo run > sequence Test the DoS prevention with this: $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar $ echo 500 > interval_msec $ time (cat version version version version version version version) Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Olof Johansson <olofj@chromium.org> Tested-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Olof Johansson <olof@lixom.net>
54 lines
1.7 KiB
C
54 lines
1.7 KiB
C
/*
|
|
* cros_ec_dev - expose the Chrome OS Embedded Controller to userspace
|
|
*
|
|
* Copyright (C) 2014 Google, Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef _CROS_EC_DEV_H_
|
|
#define _CROS_EC_DEV_H_
|
|
|
|
#include <linux/ioctl.h>
|
|
#include <linux/types.h>
|
|
#include <linux/mfd/cros_ec.h>
|
|
|
|
#define CROS_EC_DEV_NAME "cros_ec"
|
|
#define CROS_EC_DEV_VERSION "1.0.0"
|
|
|
|
/*
|
|
* @offset: within EC_LPC_ADDR_MEMMAP region
|
|
* @bytes: number of bytes to read. zero means "read a string" (including '\0')
|
|
* (at most only EC_MEMMAP_SIZE bytes can be read)
|
|
* @buffer: where to store the result
|
|
* ioctl returns the number of bytes read, negative on error
|
|
*/
|
|
struct cros_ec_readmem {
|
|
uint32_t offset;
|
|
uint32_t bytes;
|
|
uint8_t buffer[EC_MEMMAP_SIZE];
|
|
};
|
|
|
|
#define CROS_EC_DEV_IOC 0xEC
|
|
#define CROS_EC_DEV_IOCXCMD _IOWR(CROS_EC_DEV_IOC, 0, struct cros_ec_command)
|
|
#define CROS_EC_DEV_IOCRDMEM _IOWR(CROS_EC_DEV_IOC, 1, struct cros_ec_readmem)
|
|
|
|
void ec_dev_sysfs_init(struct cros_ec_device *);
|
|
void ec_dev_sysfs_remove(struct cros_ec_device *);
|
|
|
|
void ec_dev_lightbar_init(struct cros_ec_device *);
|
|
void ec_dev_lightbar_remove(struct cros_ec_device *);
|
|
|
|
#endif /* _CROS_EC_DEV_H_ */
|