summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/extcon/Kconfig2
-rw-r--r--drivers/extcon/extcon-usbc-cros-ec.c3
-rw-r--r--drivers/hid/Kconfig2
-rw-r--r--drivers/hid/hid-google-hammer.c4
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-cros-ec-tunnel.c4
-rw-r--r--drivers/iio/accel/cros_ec_accel_legacy.c3
-rw-r--r--drivers/iio/common/cros_ec_sensors/Kconfig2
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c3
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c3
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c3
-rw-r--r--drivers/iio/light/cros_ec_light_prox.c3
-rw-r--r--drivers/iio/pressure/cros_ec_baro.c3
-rw-r--r--drivers/input/keyboard/Kconfig2
-rw-r--r--drivers/input/keyboard/cros_ec_keyb.c4
-rw-r--r--drivers/media/platform/Kconfig3
-rw-r--r--drivers/media/platform/cros-ec-cec/cros-ec-cec.c5
-rw-r--r--drivers/mfd/Kconfig26
-rw-r--r--drivers/mfd/Makefile4
-rw-r--r--drivers/mfd/cros_ec_dev.c463
-rw-r--r--drivers/platform/chrome/Kconfig60
-rw-r--r--drivers/platform/chrome/Makefile2
-rw-r--r--drivers/platform/chrome/chromeos_laptop.c10
-rw-r--r--drivers/platform/chrome/chromeos_tbmc.c2
-rw-r--r--drivers/platform/chrome/cros_ec.c (renamed from drivers/mfd/cros_ec.c)64
-rw-r--r--drivers/platform/chrome/cros_ec_chardev.c419
-rw-r--r--drivers/platform/chrome/cros_ec_debugfs.c3
-rw-r--r--drivers/platform/chrome/cros_ec_i2c.c12
-rw-r--r--drivers/platform/chrome/cros_ec_ishtp.c5
-rw-r--r--drivers/platform/chrome/cros_ec_lightbar.c3
-rw-r--r--drivers/platform/chrome/cros_ec_lpc.c7
-rw-r--r--drivers/platform/chrome/cros_ec_proto.c3
-rw-r--r--drivers/platform/chrome/cros_ec_rpmsg.c57
-rw-r--r--drivers/platform/chrome/cros_ec_spi.c12
-rw-r--r--drivers/platform/chrome/cros_ec_sysfs.c3
-rw-r--r--drivers/platform/chrome/cros_ec_trace.c2
-rw-r--r--drivers/platform/chrome/cros_ec_trace.h4
-rw-r--r--drivers/platform/chrome/cros_ec_vbc.c3
-rw-r--r--drivers/platform/chrome/cros_usbpd_logger.c8
-rw-r--r--drivers/platform/chrome/wilco_ec/telemetry.c64
-rw-r--r--drivers/power/supply/Kconfig2
-rw-r--r--drivers/power/supply/cros_usbpd-charger.c5
-rw-r--r--drivers/pwm/Kconfig2
-rw-r--r--drivers/pwm/pwm-cros-ec.c4
-rw-r--r--drivers/rtc/Kconfig2
-rw-r--r--drivers/rtc/rtc-cros-ec.c3
-rw-r--r--include/Kbuild2
-rw-r--r--include/linux/iio/common/cros_ec_sensors_core.h3
-rw-r--r--include/linux/mfd/cros_ec.h292
-rw-r--r--include/linux/platform_data/cros_ec_chardev.h (renamed from drivers/mfd/cros_ec_dev.h)13
-rw-r--r--include/linux/platform_data/cros_ec_commands.h (renamed from include/linux/mfd/cros_ec_commands.h)0
-rw-r--r--include/linux/platform_data/cros_ec_proto.h319
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/cros_ec_codec.c4
-rw-r--r--sound/soc/qcom/Kconfig2
55 files changed, 1166 insertions, 778 deletions
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index fa1804460e8c..aac507bff135 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -181,7 +181,7 @@ config EXTCON_USB_GPIO
config EXTCON_USBC_CROS_EC
tristate "ChromeOS Embedded Controller EXTCON support"
- depends on MFD_CROS_EC
+ depends on CROS_EC
help
Say Y here to enable USB Type C cable detection extcon support when
using Chrome OS EC based USB Type-C ports.
diff --git a/drivers/extcon/extcon-usbc-cros-ec.c b/drivers/extcon/extcon-usbc-cros-ec.c
index 43c0a936ab82..5290cc2d19d9 100644
--- a/drivers/extcon/extcon-usbc-cros-ec.c
+++ b/drivers/extcon/extcon-usbc-cros-ec.c
@@ -6,10 +6,11 @@
#include <linux/extcon-provider.h>
#include <linux/kernel.h>
-#include <linux/mfd/cros_ec.h>
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/of.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/sched.h>
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 3872e03d9a59..a958b9625bba 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -376,7 +376,7 @@ config HOLTEK_FF
config HID_GOOGLE_HAMMER
tristate "Google Hammer Keyboard"
- depends on USB_HID && LEDS_CLASS && MFD_CROS_EC
+ depends on USB_HID && LEDS_CLASS && CROS_EC
---help---
Say Y here if you have a Google Hammer device.
diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c
index ee5e0bdcf078..84f8c127ebdc 100644
--- a/drivers/hid/hid-google-hammer.c
+++ b/drivers/hid/hid-google-hammer.c
@@ -16,9 +16,9 @@
#include <linux/acpi.h>
#include <linux/hid.h>
#include <linux/leds.h>
-#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
#include <linux/module.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
#include <linux/pm_wakeup.h>
#include <asm/unaligned.h>
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index a362245cc558..5587215b8ddb 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -1345,7 +1345,7 @@ config I2C_SIBYTE
config I2C_CROS_EC_TUNNEL
tristate "ChromeOS EC tunnel I2C bus"
- depends on MFD_CROS_EC
+ depends on CROS_EC
help
If you say yes here you get an I2C bus that will tunnel i2c commands
through to the other side of the ChromeOS EC to the i2c bus
diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
index 82bcd9a78759..c551aa96a2e3 100644
--- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c
+++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
@@ -5,8 +5,8 @@
#include <linux/module.h>
#include <linux/i2c.h>
-#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
diff --git a/drivers/iio/accel/cros_ec_accel_legacy.c b/drivers/iio/accel/cros_ec_accel_legacy.c
index 39002cb5605d..fcc3f999e482 100644
--- a/drivers/iio/accel/cros_ec_accel_legacy.c
+++ b/drivers/iio/accel/cros_ec_accel_legacy.c
@@ -19,9 +19,10 @@
#include <linux/iio/triggered_buffer.h>
#include <linux/kernel.h>
#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
#define DRV_NAME "cros-ec-accel-legacy"
diff --git a/drivers/iio/common/cros_ec_sensors/Kconfig b/drivers/iio/common/cros_ec_sensors/Kconfig
index bcb58fb76b9f..cdbb29cfb907 100644
--- a/drivers/iio/common/cros_ec_sensors/Kconfig
+++ b/drivers/iio/common/cros_ec_sensors/Kconfig
@@ -4,7 +4,7 @@
#
config IIO_CROS_EC_SENSORS_CORE
tristate "ChromeOS EC Sensors Core"
- depends on SYSFS && MFD_CROS_EC
+ depends on SYSFS && CROS_EC
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
index 876dfd176b0e..1dcc2a16ab2d 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
@@ -20,9 +20,8 @@
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/kernel.h>
-#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
#include <linux/module.h>
+#include <linux/platform_data/cros_ec_commands.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index 6a4919cd83c3..a6987726eeb8 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -17,8 +17,9 @@
#include <linux/iio/triggered_buffer.h>
#include <linux/kernel.h>
#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
#include <linux/module.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index d44ae126f457..d2609e6feda4 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -14,9 +14,10 @@
#include <linux/iio/trigger_consumer.h>
#include <linux/kernel.h>
#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
static char *cros_ec_loc[] = {
diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index 44313a009928..c5263b563fc1 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -15,8 +15,9 @@
#include <linux/iio/trigger_consumer.h>
#include <linux/kernel.h>
#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
#include <linux/module.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index 70148624db64..2354302375de 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -15,9 +15,10 @@
#include <linux/iio/trigger_consumer.h>
#include <linux/kernel.h>
#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
/*
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 2e6d2887eec1..8911bc2ec42a 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -736,7 +736,7 @@ config KEYBOARD_XTKBD
config KEYBOARD_CROS_EC
tristate "ChromeOS EC keyboard"
select INPUT_MATRIXKMAP
- depends on MFD_CROS_EC
+ depends on CROS_EC
help
Say Y here to enable the matrix keyboard used by ChromeOS devices
and implemented on the ChromeOS EC. You must enable one bus option
diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index bef7bee6f05e..8d4d9786cc74 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -22,8 +22,8 @@
#include <linux/slab.h>
#include <linux/sysrq.h>
#include <linux/input/matrix_keypad.h>
-#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <asm/unaligned.h>
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 83a785010753..f1f61419fd29 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -547,10 +547,9 @@ if CEC_PLATFORM_DRIVERS
config VIDEO_CROS_EC_CEC
tristate "ChromeOS EC CEC driver"
- depends on MFD_CROS_EC
+ depends on CROS_EC
select CEC_CORE
select CEC_NOTIFIER
- select CHROME_PLATFORMS
select CROS_EC_PROTO
help
If you say yes here you will get support for the
diff --git a/drivers/media/platform/cros-ec-cec/cros-ec-cec.c b/drivers/media/platform/cros-ec-cec/cros-ec-cec.c
index 76ab83f55cc0..4a3b3810fd89 100644
--- a/drivers/media/platform/cros-ec-cec/cros-ec-cec.c
+++ b/drivers/media/platform/cros-ec-cec/cros-ec-cec.c
@@ -14,10 +14,11 @@
#include <linux/cec.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
+#include <linux/mfd/cros_ec.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <media/cec.h>
#include <media/cec-notifier.h>
-#include <linux/mfd/cros_ec.h>
-#include <linux/mfd/cros_ec_commands.h>
#define DRV_NAME "cros-ec-cec"
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index c8cbde59bbf6..c9c49da42446 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -211,26 +211,18 @@ config MFD_AXP20X_RSB
components like regulators or the PEK (Power Enable Key) under the
corresponding menus.
-config MFD_CROS_EC
- tristate "ChromeOS Embedded Controller"
+config MFD_CROS_EC_DEV
+ tristate "ChromeOS Embedded Controller multifunction device"
select MFD_CORE
- select CHROME_PLATFORMS
- select CROS_EC_PROTO
- depends on X86 || ARM || ARM64 || COMPILE_TEST
+ depends on CROS_EC
+ default CROS_EC
help
- If you say Y here you get support for the ChromeOS Embedded
- Controller (EC) providing keyboard, battery and power services.
- You also need to enable the driver for the bus you are using. The
- protocol for talking to the EC is defined by the bus driver.
+ Select this to get support for ChromeOS Embedded Controller
+ sub-devices. This driver will instantiate additional drivers such
+ as RTC, USBPD, etc. but you have to select the individual drivers.
-config MFD_CROS_EC_CHARDEV
- tristate "Chrome OS Embedded Controller userspace device interface"
- depends on MFD_CROS_EC
- ---help---
- This driver adds support to talk with the ChromeOS EC from userspace.
-
- If you have a supported Chromebook, choose Y or M here.
- The module will be called cros_ec_dev.
+ To compile this driver as a module, choose M here: the module will be
+ called cros-ec-dev.
config MFD_MADERA
tristate "Cirrus Logic Madera codecs"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index f026ada68f6a..0c0a848e62df 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -13,9 +13,7 @@ obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o
obj-$(CONFIG_ARCH_BCM2835) += bcm2835-pm.o
obj-$(CONFIG_MFD_BCM590XX) += bcm590xx.o
obj-$(CONFIG_MFD_BD9571MWV) += bd9571mwv.o
-cros_ec_core-objs := cros_ec.o
-obj-$(CONFIG_MFD_CROS_EC) += cros_ec_core.o
-obj-$(CONFIG_MFD_CROS_EC_CHARDEV) += cros_ec_dev.o
+obj-$(CONFIG_MFD_CROS_EC_DEV) += cros_ec_dev.o
obj-$(CONFIG_MFD_EXYNOS_LPASS) += exynos-lpass.o
obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 41dccced5026..6e6dfd6c1871 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -5,73 +5,112 @@
* Copyright (C) 2014 Google, Inc.
*/
-#include <linux/fs.h>
#include <linux/mfd/core.h>
+#include <linux/mfd/cros_ec.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
-#include <linux/pm.h>
+#include <linux/platform_data/cros_ec_chardev.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
#include <linux/slab.h>
-#include <linux/uaccess.h>
-
-#include "cros_ec_dev.h"
#define DRV_NAME "cros-ec-dev"
-/* Device variables */
-#define CROS_MAX_DEV 128
-static int ec_major;
-
static struct class cros_class = {
.owner = THIS_MODULE,
.name = "chromeos",
};
-/* Basic communication */
-static int ec_get_version(struct cros_ec_dev *ec, char *str, int maxlen)
-{
- struct ec_response_get_version *resp;
- static const char * const current_image_name[] = {
- "unknown", "read-only", "read-write", "invalid",
- };
- struct cros_ec_command *msg;
- int ret;
+/**
+ * cros_feature_to_name - CrOS feature id to name/short description.
+ * @id: The feature identifier.
+ * @name: Device name associated with the feature id.
+ * @desc: Short name that will be displayed.
+ */
+struct cros_feature_to_name {
+ unsigned int id;
+ const char *name;
+ const char *desc;
+};
- msg = kmalloc(sizeof(*msg) + sizeof(*resp), GFP_KERNEL);
- if (!msg)
- return -ENOMEM;
+/**
+ * cros_feature_to_cells - CrOS feature id to mfd cells association.
+ * @id: The feature identifier.
+ * @mfd_cells: Pointer to the array of mfd cells that needs to be added.
+ * @num_cells: Number of mfd cells into the array.
+ */
+struct cros_feature_to_cells {
+ unsigned int id;
+ const struct mfd_cell *mfd_cells;
+ unsigned int num_cells;
+};
- msg->version = 0;
- msg->command = EC_CMD_GET_VERSION + ec->cmd_offset;
- msg->insize = sizeof(*resp);
- msg->outsize = 0;
-
- ret = cros_ec_cmd_xfer(ec->ec_dev, msg);
- if (ret < 0)
- goto exit;
-
- if (msg->result != EC_RES_SUCCESS) {
- snprintf(str, maxlen,
- "%s\nUnknown EC version: EC returned %d\n",
- CROS_EC_DEV_VERSION, msg->result);
- ret = -EINVAL;
- goto exit;
- }
+static const struct cros_feature_to_name cros_mcu_devices[] = {
+ {
+ .id = EC_FEATURE_FINGERPRINT,
+ .name = CROS_EC_DEV_FP_NAME,
+ .desc = "Fingerprint",
+ },
+ {
+ .id = EC_FEATURE_ISH,
+ .name = CROS_EC_DEV_ISH_NAME,
+ .desc = "Integrated Sensor Hub",
+ },
+ {
+ .id = EC_FEATURE_SCP,
+ .name = CROS_EC_DEV_SCP_NAME,
+ .desc = "System Control Processor",
+ },
+ {
+ .id = EC_FEATURE_TOUCHPAD,
+ .name = CROS_EC_DEV_TP_NAME,
+ .desc = "Touchpad",
+ },
+};
- resp = (struct ec_response_get_version *)msg->data;
- if (resp->current_image >= ARRAY_SIZE(current_image_name))
- resp->current_image = 3; /* invalid */
+static const struct mfd_cell cros_ec_cec_cells[] = {
+ { .name = "cros-ec-cec", },
+};
- snprintf(str, maxlen, "%s\n%s\n%s\n%s\n", CROS_EC_DEV_VERSION,
- resp->version_string_ro, resp->version_string_rw,
- current_image_name[resp->current_image]);
+static const struct mfd_cell cros_ec_rtc_cells[] = {
+ { .name = "cros-ec-rtc", },
+};
- ret = 0;
-exit:
- kfree(msg);
- return ret;
-}
+static const struct mfd_cell cros_usbpd_charger_cells[] = {
+ { .name = "cros-usbpd-charger", },
+ { .name = "cros-usbpd-logger", },
+};
+
+static const struct cros_feature_to_cells cros_subdevices[] = {
+ {
+ .id = EC_FEATURE_CEC,
+ .mfd_cells = cros_ec_cec_cells,
+ .num_cells = ARRAY_SIZE(cros_ec_cec_cells),
+ },
+ {
+ .id = EC_FEATURE_RTC,
+ .mfd_cells = cros_ec_rtc_cells,
+ .num_cells = ARRAY_SIZE(cros_ec_rtc_cells),
+ },
+ {
+ .id = EC_FEATURE_USB_PD,
+ .mfd_cells = cros_usbpd_charger_cells,
+ .num_cells = ARRAY_SIZE(cros_usbpd_charger_cells),
+ },
+};
+
+static const struct mfd_cell cros_ec_platform_cells[] = {
+ { .name = "cros-ec-chardev", },
+ { .name = "cros-ec-debugfs", },
+ { .name = "cros-ec-lightbar", },
+ { .name = "cros-ec-sysfs", },
+};
+
+static const struct mfd_cell cros_ec_vbc_cells[] = {
+ { .name = "cros-ec-vbc", }
+};
static int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
{
@@ -80,18 +119,15 @@ static int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
if (ec->features[0] == -1U && ec->features[1] == -1U) {
/* features bitmap not read yet */
-
- msg = kmalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL);
+ msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL);
if (!msg)
return -ENOMEM;
- msg->version = 0;
msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset;
msg->insize = sizeof(ec->features);
- msg->outsize = 0;
- ret = cros_ec_cmd_xfer(ec->ec_dev, msg);
- if (ret < 0 || msg->result != EC_RES_SUCCESS) {
+ ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+ if (ret < 0) {
dev_warn(ec->dev, "cannot get EC features: %d/%d\n",
ret, msg->result);
memset(ec->features, 0, sizeof(ec->features));
@@ -108,142 +144,6 @@ static int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
return ec->features[feature / 32] & EC_FEATURE_MASK_0(feature);
}
-/* Device file ops */
-static int ec_device_open(struct inode *inode, struct file *filp)
-{
- struct cros_ec_dev *ec = container_of(inode->i_cdev,
- struct cros_ec_dev, cdev);
- filp->private_data = ec;
- nonseekable_open(inode, filp);
- return 0;
-}
-
-static int ec_device_release(struct inode *inode, struct file *filp)
-{
- return 0;
-}
-
-static ssize_t ec_device_read(struct file *filp, char __user *buffer,
- size_t length, loff_t *offset)
-{
- struct cros_ec_dev *ec = filp->private_data;
- char msg[sizeof(struct ec_response_get_version) +
- sizeof(CROS_EC_DEV_VERSION)];
- size_t count;
- int ret;
-
- if (*offset != 0)
- return 0;
-
- ret = ec_get_version(ec, msg, sizeof(msg));
- if (ret)
- return ret;
-
- count = min(length, strlen(msg));
-
- if (copy_to_user(buffer, msg, count))
- return -EFAULT;
-
- *offset = count;
- return count;
-}
-
-/* Ioctls */
-static long ec_device_ioctl_xcmd(struct cros_ec_dev *ec, void __user *arg)
-{
- long ret;
- struct cros_ec_command u_cmd;
- struct cros_ec_command *s_cmd;
-
- if (copy_from_user(&u_cmd, arg, sizeof(u_cmd)))
- return -EFAULT;
-
- if ((u_cmd.outsize > EC_MAX_MSG_BYTES) ||
- (u_cmd.insize > EC_MAX_MSG_BYTES))
- return -EINVAL;
-
- s_cmd = kmalloc(sizeof(*s_cmd) + max(u_cmd.outsize, u_cmd.insize),
- GFP_KERNEL);
- if (!s_cmd)
- return -ENOMEM;
-
- if (copy_from_user(s_cmd, arg, sizeof(*s_cmd) + u_cmd.outsize)) {
- ret = -EFAULT;
- goto exit;
- }
-
- if (u_cmd.outsize != s_cmd->outsize ||
- u_cmd.insize != s_cmd->insize) {
- ret = -EINVAL;
- goto exit;
- }
-
- s_cmd->command += ec->cmd_offset;
- ret = cros_ec_cmd_xfer(ec->ec_dev, s_cmd);
- /* Only copy data to userland if data was received. */
- if (ret < 0)
- goto exit;
-
- if (copy_to_user(arg, s_cmd, sizeof(*s_cmd) + s_cmd->insize))
- ret = -EFAULT;
-exit:
- kfree(s_cmd);
- return ret;
-}
-
-static long ec_device_ioctl_readmem(struct cros_ec_dev *ec, void __user *arg)
-{
- struct cros_ec_device *ec_dev = ec->ec_dev;
- struct cros_ec_readmem s_mem = { };
- long num;
-
- /* Not every platform supports direct reads */
- if (!ec_dev->cmd_readmem)
- return -ENOTTY;
-
- if (copy_from_user(&s_mem, arg, sizeof(s_mem)))
- return -EFAULT;
-
- num = ec_dev->cmd_readmem(ec_dev, s_mem.offset, s_mem.bytes,
- s_mem.buffer);
- if (num <= 0)
- return num;
-
- if (copy_to_user((void __user *)arg, &s_mem, sizeof(s_mem)))
- return -EFAULT;
-
- return num;
-}
-
-static long ec_device_ioctl(struct file *filp, unsigned int cmd,
- unsigned long arg)
-{
- struct cros_ec_dev *ec = filp->private_data;
-
- if (_IOC_TYPE(cmd) != CROS_EC_DEV_IOC)
- return -ENOTTY;
-
- switch (cmd) {
- case CROS_EC_DEV_IOCXCMD:
- return ec_device_ioctl_xcmd(ec, (void __user *)arg);
- case CROS_EC_DEV_IOCRDMEM:
- return ec_device_ioctl_readmem(ec, (void __user *)arg);
- }
-
- return -ENOTTY;
-}
-
-/* Module initialization