Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BACKPORT: ChromeOS EC patches #2

Open
wants to merge 29 commits into
base: v4.16.18-galliumos
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e1120ae
platform/chrome: chromeos_laptop - stop setting suspend mode for Atme…
dtor Mar 20, 2018
3bd910a
platform/chrome: chromeos_laptop - introduce pr_fmt()
dtor Mar 20, 2018
e34e959
platform/chrome: chromeos_laptop - factor out getting IRQ from DMI
dtor Mar 20, 2018
ffa0bb3
platform/chrome: chromeos_laptop - rework i2c peripherals initialization
dtor Mar 20, 2018
2d76941
platform/chrome: chromeos_laptop - parse DMI IRQ data once
dtor Mar 20, 2018
07781ca
platform/chrome: chromeos_laptop - use I2C notifier to create devices
dtor Mar 20, 2018
1b67992
platform/chrome: chromeos_laptop - rely on I2C to set up interrupt tr…
dtor Mar 20, 2018
00c4979
platform/chrome: chromeos_laptop - use device properties for Pixel
dtor Mar 20, 2018
663de6d
platform/chrome: chromeos_laptop - discard data for unneeded boards
dtor Mar 20, 2018
fbf60df
platform/chrome: cros_ec_lpc: wake up from s2idle on Chrome EC
Feb 22, 2018
77d3e62
platform/chrome: cros_ec_lpc: Add support for Google devices using cu…
Mar 7, 2018
2a8331b
platform/chrome: cros_ec_sysfs: Modify error handling
gwendalcr Mar 23, 2018
c09fb8f
platform/chrome: cros_ec_sysfs: introduce to_cros_ec_dev define.
Mar 23, 2018
0c4f236
platform/chrome: cros_ec_sysfs: use permission-specific DEVICE_ATTR v…
Mar 23, 2018
70a4c69
platform/chrome: cros_ec_debugfs: Use octal permissions '0444'
Mar 23, 2018
975efde
platform/chrome: mfd/cros_ec_dev: Add sysfs entry to set keyboard wak…
gwendalcr Mar 23, 2018
360ca3d
platform/chrome: cros_ec_lpc: do not try DMI match when ACPI device f…
dtor May 22, 2018
2d31288
Revert "mfd: cros_ec: Add ACPI GPE handler for LID0 devices"
Feb 22, 2018
906eb67
mfd: cros_ec: Retry commands when EC is known to be busy
computersforpeace May 23, 2018
7764be9
platform: chrome: Add Tablet Switch ACPI driver
gwendalcr Jan 30, 2017
3c4c60d
platform/chrome: chromeos_laptop - supply properties for ACPI devices
dtor May 4, 2018
9107533
platform: chrome: Add input dependency for tablet switch driver
arndb May 28, 2018
a6953b2
mfd: cros_ec: Fail early if we cannot identify the EC
vpalatin Apr 18, 2018
25c5ab9
mfd: cros_ec: Free IRQ automatically
vpalatin Apr 18, 2018
4904474
mfd: cros_ec: Don't try to grab log when suspended
dianders Apr 18, 2018
a4b6301
mfd: cros_ec_dev: Register cros-ec-rtc driver as a subdevice
Apr 18, 2018
2ad83d1
mfd: cros_ec_dev: Register shutdown function for debugfs
Apr 18, 2018
f080fde
mfd: cros_ec_i2c: Add ACPI module device table
aitjcize Apr 18, 2018
09011e9
GalliumOS: Config: Enable TBMC as a module
danielstuart14 Jul 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion drivers/mfd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o
obj-$(CONFIG_MFD_BCM590XX) += bcm590xx.o
obj-$(CONFIG_MFD_BD9571MWV) += bd9571mwv.o
cros_ec_core-objs := cros_ec.o
cros_ec_core-$(CONFIG_ACPI) += cros_ec_acpi_gpe.o
obj-$(CONFIG_MFD_CROS_EC) += cros_ec_core.o
obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o
obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o
Expand Down
41 changes: 14 additions & 27 deletions drivers/mfd/cros_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,16 @@ int cros_ec_register(struct cros_ec_device *ec_dev)

mutex_init(&ec_dev->lock);

cros_ec_query_all(ec_dev);
err = cros_ec_query_all(ec_dev);
if (err) {
dev_err(dev, "Cannot identify the EC: error %d\n", err);
return err;
}

if (ec_dev->irq) {
err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread,
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"chromeos-ec", ec_dev);
err = devm_request_threaded_irq(dev, ec_dev->irq, NULL,
ec_irq_thread, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"chromeos-ec", ec_dev);
if (err) {
dev_err(dev, "Failed to request IRQ %d: %d",
ec_dev->irq, err);
Expand All @@ -131,7 +135,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
dev_err(dev,
"Failed to register Embedded Controller subdevice %d\n",
err);
goto fail_mfd;
return err;
}

if (ec_dev->max_passthru) {
Expand All @@ -149,7 +153,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
dev_err(dev,
"Failed to register Power Delivery subdevice %d\n",
err);
goto fail_mfd;
return err;
}
}

Expand All @@ -158,7 +162,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
if (err) {
mfd_remove_devices(dev);
dev_err(dev, "Failed to register sub-devices\n");
goto fail_mfd;
return err;
}
}

Expand All @@ -173,26 +177,14 @@ int cros_ec_register(struct cros_ec_device *ec_dev)

dev_info(dev, "Chrome EC device registered\n");

cros_ec_acpi_install_gpe_handler(dev);

return 0;

fail_mfd:
if (ec_dev->irq)
free_irq(ec_dev->irq, ec_dev);
return err;
}
EXPORT_SYMBOL(cros_ec_register);

int cros_ec_remove(struct cros_ec_device *ec_dev)
{
mfd_remove_devices(ec_dev->dev);

cros_ec_acpi_remove_gpe_handler();

if (ec_dev->irq)
free_irq(ec_dev->irq, ec_dev);

return 0;
}
EXPORT_SYMBOL(cros_ec_remove);
Expand All @@ -204,14 +196,9 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)
int ret;
u8 sleep_event;

if (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) {
sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND;
} else {
sleep_event = HOST_SLEEP_EVENT_S0IX_SUSPEND;

/* Clearing the GPE status for any pending event */
cros_ec_acpi_clear_gpe();
}
sleep_event = (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) ?
HOST_SLEEP_EVENT_S3_SUSPEND :
HOST_SLEEP_EVENT_S0IX_SUSPEND;

ret = cros_ec_sleep_event(ec_dev, sleep_event);
if (ret < 0)
Expand Down
103 changes: 0 additions & 103 deletions drivers/mfd/cros_ec_acpi_gpe.c

This file was deleted.

62 changes: 43 additions & 19 deletions drivers/mfd/cros_ec_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)

resp = (struct ec_response_motion_sense *)msg->data;
sensor_num = resp->dump.sensor_count;
/* Allocate 2 extra sensors in case lid angle or FIFO are needed */
sensor_cells = kzalloc(sizeof(struct mfd_cell) * (sensor_num + 2),
/* Allocate 1 extra sensors in FIFO are needed */
sensor_cells = kzalloc(sizeof(struct mfd_cell) * (sensor_num + 1),
GFP_KERNEL);
if (sensor_cells == NULL)
goto error;
Expand Down Expand Up @@ -362,16 +362,10 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
sensor_type[resp->info.type]++;
id++;
}
if (sensor_type[MOTIONSENSE_TYPE_ACCEL] >= 2) {
sensor_platforms[id].sensor_num = sensor_num;

sensor_cells[id].name = "cros-ec-angle";
sensor_cells[id].id = 0;
sensor_cells[id].platform_data = &sensor_platforms[id];
sensor_cells[id].pdata_size =
sizeof(struct cros_ec_sensor_platform);
id++;
}
if (sensor_type[MOTIONSENSE_TYPE_ACCEL] >= 2)
ec->has_kb_wake_angle = true;

if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) {
sensor_cells[id].name = "cros-ec-ring";
id++;
Expand All @@ -389,6 +383,10 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
kfree(msg);
}

static const struct mfd_cell cros_ec_rtc_cells[] = {
{ .name = "cros-ec-rtc" }
};

static int ec_device_probe(struct platform_device *pdev)
{
int retval = -ENOMEM;
Expand Down Expand Up @@ -424,6 +422,26 @@ static int ec_device_probe(struct platform_device *pdev)
goto failed;
}

/* check whether this EC is a sensor hub. */
if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE))
cros_ec_sensors_register(ec);

/* Check whether this EC instance has RTC host command support */
if (cros_ec_check_features(ec, EC_FEATURE_RTC)) {
retval = mfd_add_devices(ec->dev, PLATFORM_DEVID_AUTO,
cros_ec_rtc_cells,
ARRAY_SIZE(cros_ec_rtc_cells),
NULL, 0, NULL);
if (retval)
dev_err(ec->dev,
"failed to add cros-ec-rtc device: %d\n",
retval);
}

/* Take control of the lightbar from the EC. */
lb_manual_suspend_ctrl(ec, 1);

/* We can now add the sysfs class, we know which parameter to show */
retval = cdev_device_add(&ec->cdev, &ec->class_dev);
if (retval) {
dev_err(dev, "cdev_device_add failed => %d\n", retval);
Expand All @@ -433,13 +451,6 @@ static int ec_device_probe(struct platform_device *pdev)
if (cros_ec_debugfs_init(ec))
dev_warn(dev, "failed to create debugfs directory\n");

/* check whether this EC is a sensor hub. */
if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE))
cros_ec_sensors_register(ec);

/* Take control of the lightbar from the EC. */
lb_manual_suspend_ctrl(ec, 1);

return 0;

failed:
Expand All @@ -461,16 +472,26 @@ static int ec_device_remove(struct platform_device *pdev)
return 0;
}

static void ec_device_shutdown(struct platform_device *pdev)
{
struct cros_ec_dev *ec = dev_get_drvdata(&pdev->dev);

/* Be sure to clear up debugfs delayed works */
cros_ec_debugfs_remove(ec);
}

static const struct platform_device_id cros_ec_id[] = {
{ DRV_NAME, 0 },
{ /* sentinel */ },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(platform, cros_ec_id);

static __maybe_unused int ec_device_suspend(struct device *dev)
{
struct cros_ec_dev *ec = dev_get_drvdata(dev);

cros_ec_debugfs_suspend(ec);

lb_suspend(ec);

return 0;
Expand All @@ -480,6 +501,8 @@ static __maybe_unused int ec_device_resume(struct device *dev)
{
struct cros_ec_dev *ec = dev_get_drvdata(dev);

cros_ec_debugfs_resume(ec);

lb_resume(ec);

return 0;
Expand All @@ -499,6 +522,7 @@ static struct platform_driver cros_ec_dev_driver = {
},
.probe = ec_device_probe,
.remove = ec_device_remove,
.shutdown = ec_device_shutdown,
};

static int __init cros_ec_dev_init(void)
Expand Down
12 changes: 12 additions & 0 deletions drivers/mfd/cros_ec_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* GNU General Public License for more details.
*/

#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/module.h>
Expand Down Expand Up @@ -344,21 +345,32 @@ static int cros_ec_i2c_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(cros_ec_i2c_pm_ops, cros_ec_i2c_suspend,
cros_ec_i2c_resume);

#ifdef CONFIG_OF
static const struct of_device_id cros_ec_i2c_of_match[] = {
{ .compatible = "google,cros-ec-i2c", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, cros_ec_i2c_of_match);
#endif

static const struct i2c_device_id cros_ec_i2c_id[] = {
{ "cros-ec-i2c", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, cros_ec_i2c_id);

#ifdef CONFIG_ACPI
static const struct acpi_device_id cros_ec_i2c_acpi_id[] = {
{ "GOOG0008", 0 },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(acpi, cros_ec_i2c_acpi_id);
#endif

static struct i2c_driver cros_ec_driver = {
.driver = {
.name = "cros-ec-i2c",
.acpi_match_table = ACPI_PTR(cros_ec_i2c_acpi_id),
.of_match_table = of_match_ptr(cros_ec_i2c_of_match),
.pm = &cros_ec_i2c_pm_ops,
},
Expand Down
Loading