platform/chrome: Support for cros_ec_accel_legacy driver
v5 cover platform/chrome: Support for cros_ec_accel_legacy driver
Hi,
This series enables the legacy accelerometer driver used on Chromebook devices with older EC firmware.
The cros_ec_accel_legacy driver itself is no more part of this patchset as it has already been merged in mainline. This patchset still contains the patch that registers the cros_ec_accel_legacy driver if the usual way of registering the croc_ec sensors hub fails. This patch has been rebased on top of [1].
In addition to the cros_ec_accel_legacy driver, this series contains a fix that registers the cros_ec_lpc driver on Chromebook devices that does not have the GOOG0004 ACPI entry. In such case, the driver register the device itself. This series also adds support to the cros_ec_lpc driver for Glimmer based devices (Lenovo Yoga 11e).
[1] https://lkml.org/lkml/2017/11/20/408
Changes in v5:
- Remove the driver which is already merged
- Rebased on top of patchset [1]
Changes in v4:
- Use correct bitmask for scale channel specification
- Use precomputed scale factor value
Changes in v3:
- Use kernel-doc notation for function headers
- Add more comment to sensor ID sysfs attribute documentation
- Restore accidentally deleted comment for IIO_CHAN_INFO_CALIBBIAS handling in iio_info write_raw() callback
Changes in v2:
- Reorganize code to avoid forward declarations
- Simplify capture buffer declaration (also helps to remove forward declarations)
- Make use of iio_push_to_buffers_with_timestamp() and let the framework handle timestamp copy into capture buffer
- Added missing sysfs attribute documentation
- Few cosmetic changes here and there
Enric Balletbo i Serra (1):
platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is
missing.
Thierry Escande (2):
platform/chrome: cros_ec_lpc: Add support for Google Glimmer platform/chrome: Register cros_ec_accel_legacy driver
drivers/mfd/cros_ec_dev.c | 53 +++++++++++++++++++++++++++++++++++ drivers/platform/chrome/cros_ec_lpc.c | 41 ++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
PATCH v5 1/3 platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing.
From: Enric Balletbo i Serra <[email protected]>
Commit 12278dc7c572 ("platform/chrome: cros_ec_lpc: Add support for GOOG004 ACPI device") added support when the firmware reports the ACPI device, there are some firmwares though that doesn't report this device but have it. In such cases we need to instantiate the driver explicitly if it is not instantiated through ACPI.
--- drivers/platform/chrome/cros_ec_lpc.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_ec_lpc.c +33 -1
@@ -35,6 +35,9 @@#define DRV_NAME "cros_ec_lpcs"#define ACPI_DRV_NAME "GOOG0004" +/* True if ACPI device is present */ +static bool cros_ec_lpc_acpi_device_found; +static int ec_response_timed_out (void ) {unsigned long one_second = jiffies +HZ ;
@@ -396,9 +399,21 @@ static struct platform_driver cros_ec_lpc_driver = { .remove = cros_ec_lpc_remove, }; +static struct platform_device cros_ec_lpc_device = { + .name =DRV_NAME +}; + +static acpi_status cros_ec_lpc_parse_device (acpi_handle handle,u32 level, +void *context,void **retval) +{ + *(bool *)context = true; +return AE_CTRL_TERMINATE ; +} +static int __init cros_ec_lpc_init (void ) {int ret; +acpi_status status;if (!dmi_check_system (cros_ec_lpc_dmi_table)) {pr_err (DRV_NAME ": unsupported system.\n" );
@@ -415,11 +430,28 @@ static int __init cros_ec_lpc_init(void)return ret; } -return 0 ; + 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) { +/* Register the device, and it'll get hooked up automatically */ + ret =platform_device_register (&cros_ec_lpc_device); +if (ret) { +pr_err (DRV_NAME ": can't register device: %d\n" , ret); +platform_driver_unregister (&cros_ec_lpc_driver); +cros_ec_lpc_reg_destroy (); + } + } + +return ret; } static void __exit cros_ec_lpc_exit(void) { +if (!cros_ec_lpc_acpi_device_found) +platform_device_unregister (&cros_ec_lpc_device);platform_driver_unregister (&cros_ec_lpc_driver);cros_ec_lpc_reg_destroy (); }
Signature · 1 line
2.7.4
Re: [PATCH v5 1/3] platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing.
Checked against 7412f0a0d90ee6ddbad4cde794f88f1489422f3a (CHROMIUM:
platform/chrome: Support MKBP protocol over ACPI)
Quoted 85 lines · Thierry Escande
From: Enric Balletbo i Serra <[email protected]>
Commit
12278dc7c572("platform/chrome:cros_ec_lpc: Add support for GOOG004 ACPI device") added support when the firmware reports the ACPI device, there are some firmwares though that doesn't report this device but have it. In such cases we need to instantiate the driver explicitly if it is not instantiated through ACPI.Fixes 12278dc7c572 ("platform/chrome: cros_ec_lpc: Add support for GOOG004 ACPI device")Signed-off-by Guenter Roeck <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Signed-off-by Thierry Escande <[email protected]>--- drivers/platform/chrome/cros_ec_lpc.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)drivers/platform/chrome/cros_ec_lpc.c +33
-2@@ -35,6 +35,9 @@#define DRV_NAME "cros_ec_lpcs"#define ACPI_DRV_NAME "GOOG0004" +/* True if ACPI device is present */ +static bool cros_ec_lpc_acpi_device_found; +static int ec_response_timed_out (void ) {unsigned long one_second = jiffies +HZ ;@@ -396,9 +399,21 @@ static struct platform_driver cros_ec_lpc_driver = { .remove = cros_ec_lpc_remove, }; +static struct platform_device cros_ec_lpc_device = { + .name =DRV_NAME +}; + +static acpi_status cros_ec_lpc_parse_device (acpi_handle handle,u32 level, +void *context,void **retval) +{ + *(bool *)context = true; +return AE_CTRL_TERMINATE ; +} +static int __init cros_ec_lpc_init (void ) {int ret; +acpi_status status;if (!dmi_check_system (cros_ec_lpc_dmi_table)) {pr_err (DRV_NAME ": unsupported system.\n" );@@ -415,11 +430,28 @@ static int __init cros_ec_lpc_init(void)return ret; } -return 0 ; + 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) { +/* Register the device, and it'll get hooked up automatically */ + ret =platform_device_register (&cros_ec_lpc_device); +if (ret) { +pr_err (DRV_NAME ": can't register device: %d\n" , ret); +platform_driver_unregister (&cros_ec_lpc_driver); +cros_ec_lpc_reg_destroy (); + } + } + +return ret; } static void __exit cros_ec_lpc_exit(void) { +if (!cros_ec_lpc_acpi_device_found) +platform_device_unregister (&cros_ec_lpc_device);platform_driver_unregister (&cros_ec_lpc_driver);cros_ec_lpc_reg_destroy (); } --2.7.4
Re: [PATCH v5 1/3] platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing.
Quoted 4 lines · Gwendal Grignou
Checked against
7412f0a0d90ee6ddbad4cde794f88f1489422f3a(CHROMIUM:
platform/chrome: Support MKBP protocol over ACPI)Reviewed-by Gwendal Grignou <[email protected]>
Thanks Gwendal.
(ps, don't top post.)
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
Re: [PATCH v5 1/3] platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing.
In reply to Thierry EscandeHi Thierry,
Sorry for the delay in processing these.
Quoted 8 lines · Thierry Escande
From: Enric Balletbo i Serra <[email protected]>
Commit
12278dc7c572("platform/chrome:cros_ec_lpc: Add support for GOOG004 ACPI device") added support when the firmware reports the ACPI device, there are some firmwares though that doesn't report this device but have it. In such cases we need to instantiate the driver explicitly if it is not instantiated through ACPI.
Quoted 4 lines
Fixes 12278dc7c572 ("platform/chrome: cros_ec_lpc: Add support for GOOG004 ACPI device")Signed-off-by Guenter Roeck <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Signed-off-by Thierry Escande <[email protected]>
Applied for v4.16.
Thanks,
Benson
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
Re: [PATCH v5 1/3] platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing.
In reply to Thierry EscandeHi Thierry,
Quoted 8 lines · Thierry Escande
From: Enric Balletbo i Serra <[email protected]>
Commit
12278dc7c572("platform/chrome:cros_ec_lpc: Add support for GOOG004 ACPI device") added support when the firmware reports the ACPI device, there are some firmwares though that doesn't report this device but have it. In such cases we need to instantiate the driver explicitly if it is not instantiated through ACPI.
Quoted 4 lines
Fixes 12278dc7c572 ("platform/chrome: cros_ec_lpc: Add support for GOOG004 ACPI device")Signed-off-by Guenter Roeck <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Signed-off-by Thierry Escande <[email protected]>
Applied for v4.16.
Quoted 73 lines
--- drivers/platform/chrome/cros_ec_lpc.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)drivers/platform/chrome/cros_ec_lpc.c +33
-1@@ -35,6 +35,9 @@#define DRV_NAME "cros_ec_lpcs"#define ACPI_DRV_NAME "GOOG0004" +/* True if ACPI device is present */ +static bool cros_ec_lpc_acpi_device_found; +static int ec_response_timed_out (void ) {unsigned long one_second = jiffies +HZ ;@@ -396,9 +399,21 @@ static struct platform_driver cros_ec_lpc_driver = { .remove = cros_ec_lpc_remove, }; +static struct platform_device cros_ec_lpc_device = { + .name =DRV_NAME +}; + +static acpi_status cros_ec_lpc_parse_device (acpi_handle handle,u32 level, +void *context,void **retval) +{ + *(bool *)context = true; +return AE_CTRL_TERMINATE ; +} +static int __init cros_ec_lpc_init (void ) {int ret; +acpi_status status;if (!dmi_check_system (cros_ec_lpc_dmi_table)) {pr_err (DRV_NAME ": unsupported system.\n" );@@ -415,11 +430,28 @@ static int __init cros_ec_lpc_init(void)return ret; } -return 0 ; + 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) { +/* Register the device, and it'll get hooked up automatically */ + ret =platform_device_register (&cros_ec_lpc_device); +if (ret) { +pr_err (DRV_NAME ": can't register device: %d\n" , ret); +platform_driver_unregister (&cros_ec_lpc_driver); +cros_ec_lpc_reg_destroy (); + } + } + +return ret; } static void __exit cros_ec_lpc_exit(void) { +if (!cros_ec_lpc_acpi_device_found) +platform_device_unregister (&cros_ec_lpc_device);platform_driver_unregister (&cros_ec_lpc_driver);cros_ec_lpc_reg_destroy (); }Signature · 1 line
2.7.4
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH v5 2/3 platform/chrome: cros_ec_lpc: Add support for Google Glimmer
In reply to Thierry EscandeThis patch adds device information to the DMI table of the cros_ec_lpc driver for Google Glimmer devices. Since Google BIOS does not enumerate devices in the LPC bus, the cros_ec_lpc driver checks for system compatibility and registers the cros_ec device itself.
--- drivers/platform/chrome/cros_ec_lpc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/chrome/cros_ec_lpc.c +7 -0
@@ -365,6 +365,13 @@ static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"), }, }, + { + /* x86-glimmer, the Lenovo Thinkpad Yoga 11e. */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), + DMI_MATCH(DMI_PRODUCT_NAME, "Glimmer"), + }, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (dmi, cros_ec_lpc_dmi_table);
Signature · 1 line
2.7.4
Re: [PATCH v5 2/3] platform/chrome: cros_ec_lpc: Add support for Google Glimmer
This is not required.
Looking with dmidecode, Glimmer reports:
...
BIOS Information
Vendor: coreboot
Version: Google_Glimmer.5216.198.19...
Therefore, the first entry of cros_ec_lpc_dmi_table will match.
Gwendal.
Quoted 31 lines · Thierry Escande
This patch adds device information to the DMI table of the
cros_ec_lpcdriver for Google Glimmer devices. Since Google BIOS does not enumerate devices in the LPC bus, thecros_ec_lpcdriver checks for system compatibility and registers thecros_ecdevice itself.Signed-off-by Thierry Escande <[email protected]>--- drivers/platform/chrome/cros_ec_lpc.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/platform/chrome/cros_ec_lpc.c +7
-1@@ -365,6 +365,13 @@ static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"), }, }, + { +/* x86-glimmer, the Lenovo Thinkpad Yoga 11e. */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), + DMI_MATCH(DMI_PRODUCT_NAME, "Glimmer"), + }, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (dmi, cros_ec_lpc_dmi_table); --2.7.4
Re: [PATCH v5 2/3] platform/chrome: cros_ec_lpc: Add support for Google Glimmer
Hi Gwendal,
Quoted 9 lines · Gwendal Grignou
This is not required.
Looking with dmidecode, Glimmer reports:
...
BIOS InformationVendor: coreboot Version: Google_Glimmer.5216.198.19...
Therefore, the first entry of
cros_ec_lpc_dmi_tablewill match.
These DMI vendor/version strings are not exposed when booting in legacy mode using SeaBIOS on the Yoga 11e. Instead it matches with the pair GOOGLE/Glimmer. So this patch is needed for booting a vanilla kernel in legacy mode.
Regards,
Thierry
Quoted 36 lines
Gwendal.
Quoted 31 lines · Thierry Escande
This patch adds device information to the DMI table of the
cros_ec_lpcdriver for Google Glimmer devices. Since Google BIOS does not enumerate devices in the LPC bus, thecros_ec_lpcdriver checks for system compatibility and registers thecros_ecdevice itself.Signed-off-by Thierry Escande <[email protected]>--- drivers/platform/chrome/cros_ec_lpc.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/platform/chrome/cros_ec_lpc.c +7
-1@@ -365,6 +365,13 @@ static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"), }, }, + { +/* x86-glimmer, the Lenovo Thinkpad Yoga 11e. */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), + DMI_MATCH(DMI_PRODUCT_NAME, "Glimmer"), + }, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (dmi, cros_ec_lpc_dmi_table); --2.7.4
Gwendal Grignou
Reviewed-byRe: [PATCH v5 2/3] platform/chrome: cros_ec_lpc: Add support for Google Glimmer
Quoted 12 lines · Thierry Escande
Hi Gwendal,
Quoted 9 lines · Gwendal Grignou
This is not required.
Looking with dmidecode, Glimmer reports:
...
BIOS InformationVendor: coreboot Version: Google_Glimmer.5216.198.19...
Quoted 7 lines
Quoted 1 line
Therefore, the first entry of
cros_ec_lpc_dmi_tablewill match.These DMI vendor/version strings are not exposed when booting in legacy mode using SeaBIOS on the Yoga 11e. Instead it matches with the pair GOOGLE/Glimmer. So this patch is needed for booting a vanilla kernel in legacy mode.
Good point. Given we will have the same issue with TianoCore, we have to use a DMI product match. Newer ACPI based chromebooks registers their EC dynamically , but looking at cros_ec_lpc.c, all registrations are gated on a dmi table match. This is only required for older devices.
In the meantime,
Quoted 44 lines
Regards,
ThierryQuoted 39 lines
Gwendal.
Quoted 34 lines · Thierry Escande
This patch adds device information to the DMI table of the
cros_ec_lpcdriver for Google Glimmer devices. Since Google BIOS does not enumerate devices in the LPC bus, thecros_ec_lpcdriver checks for system compatibility and registers thecros_ecdevice itself.Signed-off-by Thierry Escande <[email protected]>--- drivers/platform/chrome/cros_ec_lpc.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/platform/chrome/cros_ec_lpc.c +7
-0@@ -365,6 +365,13 @@ static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"), }, }, + { +/* x86-glimmer, the Lenovo Thinkpad Yoga 11e. */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"GOOGLE" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Glimmer"), + }, + }, { /* sentinel */ } };
MODULE_DEVICE_TABLE(dmi, cros_ec_lpc_dmi_table);
--
2.7.4
Benson Leung
AppliedRe: [PATCH v5 2/3] platform/chrome: cros_ec_lpc: Add support for Google Glimmer
In reply to Thierry EscandeHi Thierry,
Quoted 6 lines · Thierry Escande
This patch adds device information to the DMI table of the
cros_ec_lpcdriver for Google Glimmer devices. Since Google BIOS does not enumerate devices in the LPC bus, thecros_ec_lpcdriver checks for system compatibility and registers thecros_ecdevice itself.Signed-off-by Thierry Escande <[email protected]>
Applied. Thanks.
Quoted 25 lines
--- drivers/platform/chrome/cros_ec_lpc.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/platform/chrome/cros_ec_lpc.c +7
-0@@ -365,6 +365,13 @@ static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"), }, }, + { + /* x86-glimmer, the Lenovo Thinkpad Yoga 11e. */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), + DMI_MATCH(DMI_PRODUCT_NAME, "Glimmer"), + }, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (dmi, cros_ec_lpc_dmi_table);Signature · 1 line
2.7.4
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH v5 3/3 platform/chrome: Register cros_ec_accel_legacy driver
In reply to Thierry EscandeWith this patch, the cros_ec_ctl driver will register the legacy accelerometer driver (named cros_ec_accel_legacy) if it fails to register sensors through the usual path cros_ec_sensors_register(). This legacy device is present on Chromebook devices with older EC firmware only supporting deprecated EC commands (Glimmer based devices).
--- drivers/mfd/cros_ec_dev.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/mfd/cros_ec_dev.c +53 -0
@@ -389,6 +389,56 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)kfree (msg); } +#define CROS_EC_SENSOR_LEGACY_NUM 2 +static struct mfd_cell cros_ec_accel_legacy_cells[CROS_EC_SENSOR_LEGACY_NUM ]; + +static void cros_ec_accel_legacy_register (struct cros_ec_dev *ec) +{ +struct cros_ec_device *ec_dev = ec->ec_dev; +u8 status; +int i, ret; +struct cros_ec_sensor_platform + sensor_platforms[CROS_EC_SENSOR_LEGACY_NUM ]; + +/* +* Check if EC supports direct memory reads and if EC has +* accelerometers. +*/ +if (!ec_dev->cmd_readmem) +return ; + + ret = ec_dev->cmd_readmem (ec_dev,EC_MEMMAP_ACC_STATUS ,1 , &status); +if (ret <0 ) { +dev_warn (ec->dev,"EC does not support direct reads.\n" ); +return ; + } + +/* Check if EC has accelerometers. */ +if (!(status &EC_MEMMAP_ACC_STATUS_PRESENCE_BIT )) { +dev_info (ec->dev,"EC does not have accelerometers.\n" ); +return ; + } + +/* +* Register 2 accelerometers +*/ +for (i =0 ; i <CROS_EC_SENSOR_LEGACY_NUM ; i++) { + cros_ec_accel_legacy_cells[i].name ="cros-ec-accel-legacy" ; + sensor_platforms[i].sensor_num = i; + cros_ec_accel_legacy_cells[i].id = i; + cros_ec_accel_legacy_cells[i].platform_data = + &sensor_platforms[i]; + cros_ec_accel_legacy_cells[i].pdata_size = +sizeof (struct cros_ec_sensor_platform ); + } + ret =mfd_add_devices (ec->dev,PLATFORM_DEVID_AUTO , + cros_ec_accel_legacy_cells, +CROS_EC_SENSOR_LEGACY_NUM , +NULL ,0 ,NULL ); +if (ret) +dev_err (ec_dev->dev,"failed to add EC sensors\n" ); +} +static int ec_device_probe (struct platform_device *pdev) {int retval = -ENOMEM ;
@@ -436,6 +486,9 @@ static int ec_device_probe(struct platform_device *pdev)/* check whether this EC is a sensor hub. */ if (cros_ec_check_features (ec,EC_FEATURE_MOTION_SENSE ))cros_ec_sensors_register (ec); +else +/* Workaroud for older EC firmware */ +cros_ec_accel_legacy_register (ec);/* Take control of the lightbar from the EC. */ lb_manual_suspend_ctrl (ec,1 );
Signature · 1 line
2.7.4
Re: [PATCH v5 3/3] platform/chrome: Register cros_ec_accel_legacy driver
Checked against 3bf98755f9c670c5c10ca05cba22848d65117cb2 (CHROMIUM:
iio: accel: Add cros_ec_accel_legacy driver)
Fixup f2b141a242e59017dbc774dc916748670a41da0b (FIXUP: CHROMIUM: iio:
accel: Add cros_ec_accel_legacy driver) is required for devices with secondary Embedded Controllers.
Gwendal.
Quoted 85 lines · Thierry Escande
With this patch, the
cros_ec_ctldriver will register the legacy accelerometer driver (namedcros_ec_accel_legacy) if it fails to register sensors through the usual pathcros_ec_sensors_register(). This legacy device is present on Chromebook devices with older EC firmware only supporting deprecated EC commands (Glimmer based devices).Signed-off-by Thierry Escande <[email protected]>--- drivers/mfd/cros_ec_dev.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)drivers/mfd/cros_ec_dev.c +53
-1@@ -389,6 +389,56 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)kfree (msg); } +#define CROS_EC_SENSOR_LEGACY_NUM 2 +static struct mfd_cell cros_ec_accel_legacy_cells[CROS_EC_SENSOR_LEGACY_NUM ]; + +static void cros_ec_accel_legacy_register (struct cros_ec_dev *ec) +{ +struct cros_ec_device *ec_dev = ec->ec_dev; +u8 status; +int i, ret; +struct cros_ec_sensor_platform + sensor_platforms[CROS_EC_SENSOR_LEGACY_NUM ]; + +/* +* Check if EC supports direct memory reads and if EC has +* accelerometers. +*/ +if (!ec_dev->cmd_readmem) +return ; + + ret = ec_dev->cmd_readmem (ec_dev,EC_MEMMAP_ACC_STATUS ,1 , &status); +if (ret <0 ) { +dev_warn (ec->dev,"EC does not support direct reads.\n" ); +return ; + } + +/* Check if EC has accelerometers. */ +if (!(status &EC_MEMMAP_ACC_STATUS_PRESENCE_BIT )) { +dev_info (ec->dev,"EC does not have accelerometers.\n" ); +return ; + } + +/* +* Register 2 accelerometers +*/ +for (i =0 ; i <CROS_EC_SENSOR_LEGACY_NUM ; i++) { + cros_ec_accel_legacy_cells[i].name ="cros-ec-accel-legacy" ; + sensor_platforms[i].sensor_num = i; + cros_ec_accel_legacy_cells[i].id = i; + cros_ec_accel_legacy_cells[i].platform_data = + &sensor_platforms[i]; + cros_ec_accel_legacy_cells[i].pdata_size = +sizeof (struct cros_ec_sensor_platform ); + } + ret =mfd_add_devices (ec->dev,PLATFORM_DEVID_AUTO , + cros_ec_accel_legacy_cells, +CROS_EC_SENSOR_LEGACY_NUM , +NULL ,0 ,NULL ); +if (ret) +dev_err (ec_dev->dev,"failed to add EC sensors\n" ); +} +static int ec_device_probe (struct platform_device *pdev) {int retval = -ENOMEM ;@@ -436,6 +486,9 @@ static int ec_device_probe(struct platform_device *pdev)/* check whether this EC is a sensor hub. */ if (cros_ec_check_features (ec,EC_FEATURE_MOTION_SENSE ))cros_ec_sensors_register (ec); +else +/* Workaroud for older EC firmware */ +cros_ec_accel_legacy_register (ec);/* Take control of the lightbar from the EC. */ lb_manual_suspend_ctrl (ec,1 ); --2.7.4
Re: [PATCH v5 3/3] platform/chrome: Register cros_ec_accel_legacy driver
Quoted 6 lines · Gwendal Grignou
Checked against
3bf98755f9c670c5c10ca05cba22848d65117cb2(CHROMIUM:
iio: accel: Addcros_ec_accel_legacydriver)Fixup
f2b141a242e59017dbc774dc916748670a41da0b(FIXUP: CHROMIUM: iio:
accel: Addcros_ec_accel_legacydriver) is required for devices with secondary Embedded Controllers.
Is that an Ack or a NAck?
And pleeeeeease don't top post.
Quoted 12 lines
Quoted 10 lines · Thierry Escande
With this patch, the
cros_ec_ctldriver will register the legacy accelerometer driver (namedcros_ec_accel_legacy) if it fails to register sensors through the usual pathcros_ec_sensors_register(). This legacy device is present on Chromebook devices with older EC firmware only supporting deprecated EC commands (Glimmer based devices).Signed-off-by Thierry Escande <[email protected]>--- drivers/mfd/cros_ec_dev.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
[...]
Signature · 4 lines
Lee Jones Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v5 3/3] platform/chrome: Register cros_ec_accel_legacy driver
Quoted 10 lines · Lee Jones
Quoted 6 lines · Gwendal Grignou
Checked against
3bf98755f9c670c5c10ca05cba22848d65117cb2(CHROMIUM:
iio: accel: Addcros_ec_accel_legacydriver)Fixup
f2b141a242e59017dbc774dc916748670a41da0b(FIXUP: CHROMIUM: iio:
accel: Addcros_ec_accel_legacydriver) is required for devices with secondary Embedded Controllers.Is that an Ack or a NAck?
My response was incomplete: it is a nack.
Thierry's patch does match 3bf98755f9, but patch f2b141a242e should be merged in.
Quoted 2 lines
And pleeeeeease don't top post.
Sorry,
Gwendal.
Quoted 21 lines
Quoted 9 lines
Quoted 6 lines · Thierry Escande
With this patch, the
cros_ec_ctldriver will register the legacy accelerometer driver (namedcros_ec_accel_legacy) if it fails to register sensors through the usual pathcros_ec_sensors_register(). This legacy device is present on Chromebook devices with older EC firmware only supporting deprecated EC commands (Glimmer based devices).Quoted 4 lines
Quoted 4 lines
Signed-off-by Thierry Escande <[email protected]>--- drivers/mfd/cros_ec_dev.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)[...]
--
Lee Jones
Linaro Services Technical LeadLinaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog