Commit 910470e0 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'chrome-platform-for-linus-4.18' of...

Merge tag 'chrome-platform-for-linus-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform

Pull chrome platform updates from Benson Leung:

 - further changes from Dmitry related to the removal of platform data
   from atmel_mxt_ts and chromeos_laptop.

   This time, we have some changes that teach chromeos_laptop how to
   supply acpi properties for some input devices so that the peripheral
   driver doesn't have to do dmi matching on some Chromebook platforms.

 - new Chromebook Tablet switch driver, which is useful for x86
   convertible Chromebooks.

 - other misc cleanup

* tag 'chrome-platform-for-linus-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform:
  platform/chrome: Use to_cros_ec_dev more broadly
  platform/chrome: chromeos_laptop: fix touchpad button mapping on Celes
  platform: chrome: Add input dependency for tablet switch driver
  platform/chrome: chromeos_laptop - supply properties for ACPI devices
  platform/chrome: chromeos_tbmc - add SPDX identifier
  platform: chrome: Add Tablet Switch ACPI driver
  platform/chrome: cros_ec_lpc: do not try DMI match when ACPI device found
parents bef82f81 79a3d603
...@@ -38,6 +38,17 @@ config CHROMEOS_PSTORE ...@@ -38,6 +38,17 @@ config CHROMEOS_PSTORE
If you have a supported Chromebook, choose Y or M here. If you have a supported Chromebook, choose Y or M here.
The module will be called chromeos_pstore. The module will be called chromeos_pstore.
config CHROMEOS_TBMC
tristate "ChromeOS Tablet Switch Controller"
depends on ACPI
depends on INPUT
help
This option adds a driver for the tablet switch on
select Chrome OS systems.
To compile this driver as a module, choose M here: the
module will be called chromeos_tbmc.
config CROS_EC_CTL config CROS_EC_CTL
tristate tristate
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o
obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o
obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o
cros_ec_ctl-objs := cros_ec_sysfs.o cros_ec_lightbar.o \ cros_ec_ctl-objs := cros_ec_sysfs.o cros_ec_lightbar.o \
cros_ec_vbc.o cros_ec_debugfs.o cros_ec_vbc.o cros_ec_debugfs.o
obj-$(CONFIG_CROS_EC_CTL) += cros_ec_ctl.o obj-$(CONFIG_CROS_EC_CTL) += cros_ec_ctl.o
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0+
// Driver to detect Tablet Mode for ChromeOS convertible.
//
// Copyright (C) 2017 Google, Inc.
// Author: Gwendal Grignou <gwendal@chromium.org>
#include <linux/acpi.h>
#include <linux/input.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/printk.h>
#define DRV_NAME "chromeos_tbmc"
#define ACPI_DRV_NAME "GOOG0006"
static int chromeos_tbmc_query_switch(struct acpi_device *adev,
struct input_dev *idev)
{
unsigned long long state;
acpi_status status;
status = acpi_evaluate_integer(adev->handle, "TBMC", NULL, &state);
if (ACPI_FAILURE(status))
return -ENODEV;
/* input layer checks if event is redundant */
input_report_switch(idev, SW_TABLET_MODE, state);
input_sync(idev);
return 0;
}
static __maybe_unused int chromeos_tbmc_resume(struct device *dev)
{
struct acpi_device *adev = to_acpi_device(dev);
return chromeos_tbmc_query_switch(adev, adev->driver_data);
}
static void chromeos_tbmc_notify(struct acpi_device *adev, u32 event)
{
switch (event) {
case 0x80:
chromeos_tbmc_query_switch(adev, adev->driver_data);
break;
default:
dev_err(&adev->dev, "Unexpected event: 0x%08X\n", event);
}
}
static int chromeos_tbmc_open(struct input_dev *idev)
{
struct acpi_device *adev = input_get_drvdata(idev);
return chromeos_tbmc_query_switch(adev, idev);
}
static int chromeos_tbmc_add(struct acpi_device *adev)
{
struct input_dev *idev;
struct device *dev = &adev->dev;
int ret;
idev = devm_input_allocate_device(dev);
if (!idev)
return -ENOMEM;
idev->name = "Tablet Mode Switch";
idev->phys = acpi_device_hid(adev);
idev->id.bustype = BUS_HOST;
idev->id.version = 1;
idev->id.product = 0;
idev->open = chromeos_tbmc_open;
input_set_drvdata(idev, adev);
adev->driver_data = idev;
input_set_capability(idev, EV_SW, SW_TABLET_MODE);
ret = input_register_device(idev);
if (ret) {
dev_err(dev, "cannot register input device\n");
return ret;
}
return 0;
}
static const struct acpi_device_id chromeos_tbmc_acpi_device_ids[] = {
{ ACPI_DRV_NAME, 0 },
{ }
};
MODULE_DEVICE_TABLE(acpi, chromeos_tbmc_acpi_device_ids);
static const SIMPLE_DEV_PM_OPS(chromeos_tbmc_pm_ops, NULL,
chromeos_tbmc_resume);
static struct acpi_driver chromeos_tbmc_driver = {
.name = DRV_NAME,
.class = DRV_NAME,
.ids = chromeos_tbmc_acpi_device_ids,
.ops = {
.add = chromeos_tbmc_add,
.notify = chromeos_tbmc_notify,
},
.drv.pm = &chromeos_tbmc_pm_ops,
};
module_acpi_driver(chromeos_tbmc_driver);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("ChromeOS ACPI tablet switch driver");
...@@ -170,8 +170,7 @@ static ssize_t version_show(struct device *dev, ...@@ -170,8 +170,7 @@ static ssize_t version_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
uint32_t version = 0, flags = 0; uint32_t version = 0, flags = 0;
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
struct cros_ec_dev, class_dev);
int ret; int ret;
ret = lb_throttle(); ret = lb_throttle();
...@@ -193,8 +192,7 @@ static ssize_t brightness_store(struct device *dev, ...@@ -193,8 +192,7 @@ static ssize_t brightness_store(struct device *dev,
struct cros_ec_command *msg; struct cros_ec_command *msg;
int ret; int ret;
unsigned int val; unsigned int val;
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
struct cros_ec_dev, class_dev);
if (kstrtouint(buf, 0, &val)) if (kstrtouint(buf, 0, &val))
return -EINVAL; return -EINVAL;
...@@ -238,8 +236,7 @@ static ssize_t led_rgb_store(struct device *dev, struct device_attribute *attr, ...@@ -238,8 +236,7 @@ static ssize_t led_rgb_store(struct device *dev, struct device_attribute *attr,
{ {
struct ec_params_lightbar *param; struct ec_params_lightbar *param;
struct cros_ec_command *msg; struct cros_ec_command *msg;
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
struct cros_ec_dev, class_dev);
unsigned int val[4]; unsigned int val[4];
int ret, i = 0, j = 0, ok = 0; int ret, i = 0, j = 0, ok = 0;
...@@ -311,8 +308,7 @@ static ssize_t sequence_show(struct device *dev, ...@@ -311,8 +308,7 @@ static ssize_t sequence_show(struct device *dev,
struct ec_response_lightbar *resp; struct ec_response_lightbar *resp;
struct cros_ec_command *msg; struct cros_ec_command *msg;
int ret; int ret;
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
struct cros_ec_dev, class_dev);
msg = alloc_lightbar_cmd_msg(ec); msg = alloc_lightbar_cmd_msg(ec);
if (!msg) if (!msg)
...@@ -439,8 +435,7 @@ static ssize_t sequence_store(struct device *dev, struct device_attribute *attr, ...@@ -439,8 +435,7 @@ static ssize_t sequence_store(struct device *dev, struct device_attribute *attr,
struct cros_ec_command *msg; struct cros_ec_command *msg;
unsigned int num; unsigned int num;
int ret, len; int ret, len;
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
struct cros_ec_dev, class_dev);
for (len = 0; len < count; len++) for (len = 0; len < count; len++)
if (!isalnum(buf[len])) if (!isalnum(buf[len]))
...@@ -488,8 +483,7 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr, ...@@ -488,8 +483,7 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr,
int extra_bytes, max_size, ret; int extra_bytes, max_size, ret;
struct ec_params_lightbar *param; struct ec_params_lightbar *param;
struct cros_ec_command *msg; struct cros_ec_command *msg;
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
class_dev);
/* /*
* We might need to reject the program for size reasons. The EC * We might need to reject the program for size reasons. The EC
...@@ -599,8 +593,7 @@ static umode_t cros_ec_lightbar_attrs_are_visible(struct kobject *kobj, ...@@ -599,8 +593,7 @@ static umode_t cros_ec_lightbar_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n) struct attribute *a, int n)
{ {
struct device *dev = container_of(kobj, struct device, kobj); struct device *dev = container_of(kobj, struct device, kobj);
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
struct cros_ec_dev, class_dev);
struct platform_device *pdev = to_platform_device(ec->dev); struct platform_device *pdev = to_platform_device(ec->dev);
struct cros_ec_platform *pdata = pdev->dev.platform_data; struct cros_ec_platform *pdata = pdev->dev.platform_data;
int is_cros_ec; int is_cros_ec;
......
...@@ -435,7 +435,13 @@ static int __init cros_ec_lpc_init(void) ...@@ -435,7 +435,13 @@ static int __init cros_ec_lpc_init(void)
int ret; int ret;
acpi_status status; acpi_status status;
if (!dmi_check_system(cros_ec_lpc_dmi_table)) { status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device,
&cros_ec_lpc_acpi_device_found, NULL);
if (ACPI_FAILURE(status))
pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME);
if (!cros_ec_lpc_acpi_device_found &&
!dmi_check_system(cros_ec_lpc_dmi_table)) {
pr_err(DRV_NAME ": unsupported system.\n"); pr_err(DRV_NAME ": unsupported system.\n");
return -ENODEV; return -ENODEV;
} }
...@@ -450,11 +456,6 @@ static int __init cros_ec_lpc_init(void) ...@@ -450,11 +456,6 @@ static int __init cros_ec_lpc_init(void)
return ret; return ret;
} }
status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device,
&cros_ec_lpc_acpi_device_found, NULL);
if (ACPI_FAILURE(status))
pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME);
if (!cros_ec_lpc_acpi_device_found) { if (!cros_ec_lpc_acpi_device_found) {
/* Register the device, and it'll get hooked up automatically */ /* Register the device, and it'll get hooked up automatically */
ret = platform_device_register(&cros_ec_lpc_device); ret = platform_device_register(&cros_ec_lpc_device);
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#define to_cros_ec_dev(dev) container_of(dev, struct cros_ec_dev, class_dev)
/* Accessor functions */ /* Accessor functions */
static ssize_t reboot_show(struct device *dev, static ssize_t reboot_show(struct device *dev,
......
...@@ -29,8 +29,7 @@ static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj, ...@@ -29,8 +29,7 @@ static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj,
loff_t pos, size_t count) loff_t pos, size_t count)
{ {
struct device *dev = container_of(kobj, struct device, kobj); struct device *dev = container_of(kobj, struct device, kobj);
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
class_dev);
struct cros_ec_device *ecdev = ec->ec_dev; struct cros_ec_device *ecdev = ec->ec_dev;
struct ec_params_vbnvcontext *params; struct ec_params_vbnvcontext *params;
struct cros_ec_command *msg; struct cros_ec_command *msg;
...@@ -70,8 +69,7 @@ static ssize_t vboot_context_write(struct file *filp, struct kobject *kobj, ...@@ -70,8 +69,7 @@ static ssize_t vboot_context_write(struct file *filp, struct kobject *kobj,
loff_t pos, size_t count) loff_t pos, size_t count)
{ {
struct device *dev = container_of(kobj, struct device, kobj); struct device *dev = container_of(kobj, struct device, kobj);
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
class_dev);
struct cros_ec_device *ecdev = ec->ec_dev; struct cros_ec_device *ecdev = ec->ec_dev;
struct ec_params_vbnvcontext *params; struct ec_params_vbnvcontext *params;
struct cros_ec_command *msg; struct cros_ec_command *msg;
...@@ -111,8 +109,7 @@ static umode_t cros_ec_vbc_is_visible(struct kobject *kobj, ...@@ -111,8 +109,7 @@ static umode_t cros_ec_vbc_is_visible(struct kobject *kobj,
struct bin_attribute *a, int n) struct bin_attribute *a, int n)
{ {
struct device *dev = container_of(kobj, struct device, kobj); struct device *dev = container_of(kobj, struct device, kobj);
struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, struct cros_ec_dev *ec = to_cros_ec_dev(dev);
class_dev);
struct device_node *np = ec->ec_dev->dev->of_node; struct device_node *np = ec->ec_dev->dev->of_node;
if (IS_ENABLED(CONFIG_OF) && np) { if (IS_ENABLED(CONFIG_OF) && np) {
......
...@@ -197,6 +197,8 @@ struct cros_ec_dev { ...@@ -197,6 +197,8 @@ struct cros_ec_dev {
u32 features[2]; u32 features[2];
}; };
#define to_cros_ec_dev(dev) container_of(dev, struct cros_ec_dev, class_dev)
/** /**
* cros_ec_suspend - Handle a suspend operation for the ChromeOS EC device * cros_ec_suspend - Handle a suspend operation for the ChromeOS EC device
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment