From da3b0ab75aadab63d1ffd5563100c9386e444dad Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Tue, 17 Jun 2014 14:02:00 -0700 Subject: platform/chrome: chromeos_laptop - Add support for Acer C720 Acer C720 has touchpad and light sensor connected to a separate I2C buses. Since the designware I2C host controller driver has two instances on this particular machine we need a way to match the correct instance. Add support for this and then register both C720 touchpad and light sensor. This code is based on following patch from Benson Leung: https://patchwork.kernel.org/patch/3074411/ Signed-off-by: Mika Westerberg Tested-by: Kirill A. Shutemov Signed-off-by: Benson Leung Reviewed-by: Mika Westerberg Signed-off-by: Olof Johansson --- drivers/platform/chrome/chromeos_laptop.c | 45 ++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'drivers/platform/chrome/chromeos_laptop.c') diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c index 7f1a2e2711bd..a241e5fa6c83 100644 --- a/drivers/platform/chrome/chromeos_laptop.c +++ b/drivers/platform/chrome/chromeos_laptop.c @@ -45,6 +45,8 @@ static const char *i2c_adapter_names[] = { "SMBus I801 adapter", "i915 gmbus vga", "i915 gmbus panel", + "i2c-designware-pci", + "i2c-designware-pci", }; /* Keep this enum consistent with i2c_adapter_names */ @@ -52,6 +54,8 @@ enum i2c_adapter_type { I2C_ADAPTER_SMBUS = 0, I2C_ADAPTER_VGADDC, I2C_ADAPTER_PANEL, + I2C_ADAPTER_DESIGNWARE_0, + I2C_ADAPTER_DESIGNWARE_1, }; struct i2c_peripheral { @@ -172,29 +176,42 @@ static struct i2c_client *__add_probed_i2c_device( return client; } +struct i2c_lookup { + const char *name; + int instance; + int n; +}; + static int __find_i2c_adap(struct device *dev, void *data) { - const char *name = data; + struct i2c_lookup *lookup = data; static const char *prefix = "i2c-"; struct i2c_adapter *adapter; if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0) return 0; adapter = to_i2c_adapter(dev); - return (strncmp(adapter->name, name, strlen(name)) == 0); + if (strncmp(adapter->name, lookup->name, strlen(lookup->name)) == 0 && + lookup->n++ == lookup->instance) + return 1; + return 0; } static int find_i2c_adapter_num(enum i2c_adapter_type type) { struct device *dev = NULL; struct i2c_adapter *adapter; - const char *name = i2c_adapter_names[type]; + struct i2c_lookup lookup; + + memset(&lookup, 0, sizeof(lookup)); + lookup.name = i2c_adapter_names[type]; + lookup.instance = (type == I2C_ADAPTER_DESIGNWARE_1) ? 1 : 0; + /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); + dev = bus_find_device(&i2c_bus_type, NULL, &lookup, __find_i2c_adap); if (!dev) { /* Adapters may appear later. Deferred probing will retry */ pr_notice("%s: i2c adapter %s not found on system.\n", __func__, - name); + lookup.name); return -ENODEV; } adapter = to_i2c_adapter(dev); @@ -377,6 +394,15 @@ static struct chromeos_laptop acer_ac700 = { }, }; +static struct chromeos_laptop acer_c720 = { + .i2c_peripherals = { + /* Touchpad. */ + { .add = setup_cyapa_tp, I2C_ADAPTER_DESIGNWARE_0 }, + /* Light Sensor. */ + { .add = setup_isl29018_als, I2C_ADAPTER_DESIGNWARE_1 }, + }, +}; + static struct chromeos_laptop hp_pavilion_14_chromebook = { .i2c_peripherals = { /* Touchpad. */ @@ -433,6 +459,13 @@ static struct dmi_system_id chromeos_laptop_dmi_table[] __initdata = { }, _CBDD(acer_ac700), }, + { + .ident = "Acer C720", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"), + }, + _CBDD(acer_c720), + }, { .ident = "HP Pavilion 14 Chromebook", .matches = { -- cgit v1.2.3-59-g8ed1b From 5ea9567f6126846f5dcfa8515d7ef2c238133c0d Mon Sep 17 00:00:00 2001 From: Benson Leung Date: Tue, 17 Jun 2014 14:02:01 -0700 Subject: platform/chrome: chromeos_laptop - Add HP Chromebook 14 Add support for the trackpad on HP Chromebook 14. Signed-off-by: Benson Leung Reviewed-by: Mika Westerberg Signed-off-by: Olof Johansson --- drivers/platform/chrome/chromeos_laptop.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers/platform/chrome/chromeos_laptop.c') diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c index a241e5fa6c83..02e014b8927c 100644 --- a/drivers/platform/chrome/chromeos_laptop.c +++ b/drivers/platform/chrome/chromeos_laptop.c @@ -380,6 +380,13 @@ static struct chromeos_laptop chromebook_pixel = { }, }; +static struct chromeos_laptop hp_chromebook_14 = { + .i2c_peripherals = { + /* Touchpad. */ + { .add = setup_cyapa_tp, I2C_ADAPTER_DESIGNWARE_0 }, + }, +}; + static struct chromeos_laptop acer_c7_chromebook = { .i2c_peripherals = { /* Touchpad. */ @@ -445,6 +452,14 @@ static struct dmi_system_id chromeos_laptop_dmi_table[] __initdata = { }, _CBDD(chromebook_pixel), }, + { + .ident = "HP Chromebook 14", + .matches = { + DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"), + DMI_MATCH(DMI_PRODUCT_NAME, "Falco"), + }, + _CBDD(hp_chromebook_14), + }, { .ident = "Acer C7 Chromebook", .matches = { -- cgit v1.2.3-59-g8ed1b From 0e1e5e590a457063c94d55c219b349bcf0d1f93a Mon Sep 17 00:00:00 2001 From: Mohammed Habibulla Date: Tue, 17 Jun 2014 14:02:02 -0700 Subject: platform/chrome: chromeos_laptop - Add Dell Chromebook 11 touch Add support for Dell Chromebook 11's touch device, which is the same as falco/peppy on the same bus using the LynxPoint-LP I2C via the i2c-designware-pci driver. Based on these patches from the chromeos-3.8 kernel: https://chromium-review.googlesource.com/#/c/65320/ https://chromium-review.googlesource.com/#/c/174664/ Signed-off-by: Mohammed Habibulla Signed-off-by: Benson Leung Reviewed-by: Mika Westerberg Signed-off-by: Olof Johansson --- drivers/platform/chrome/chromeos_laptop.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers/platform/chrome/chromeos_laptop.c') diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c index 02e014b8927c..e0a671075b28 100644 --- a/drivers/platform/chrome/chromeos_laptop.c +++ b/drivers/platform/chrome/chromeos_laptop.c @@ -387,6 +387,13 @@ static struct chromeos_laptop hp_chromebook_14 = { }, }; +static struct chromeos_laptop dell_chromebook_11 = { + .i2c_peripherals = { + /* Touchpad. */ + { .add = setup_cyapa_tp, I2C_ADAPTER_DESIGNWARE_0 }, + }, +}; + static struct chromeos_laptop acer_c7_chromebook = { .i2c_peripherals = { /* Touchpad. */ @@ -452,6 +459,14 @@ static struct dmi_system_id chromeos_laptop_dmi_table[] __initdata = { }, _CBDD(chromebook_pixel), }, + { + .ident = "Wolf", + .matches = { + DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"), + DMI_MATCH(DMI_PRODUCT_NAME, "Wolf"), + }, + _CBDD(dell_chromebook_11), + }, { .ident = "HP Chromebook 14", .matches = { -- cgit v1.2.3-59-g8ed1b From 963cb6fa0f5f115986e970b9d97440e4906524fa Mon Sep 17 00:00:00 2001 From: Gene Chen Date: Tue, 17 Jun 2014 14:02:03 -0700 Subject: platform/chrome: chromeos_laptop - Add Toshiba CB35 Touch Add support for Leon touch devices, which is the same as falco/peppy/wolf on the same buses using the LynxPoint-LP I2C via the i2c-designware-pci driver. Based on these patches from the chromeos-3.8 kernel: https://chromium-review.googlesource.com/168351 https://chromium-review.googlesource.com/173445 Signed-off-by: Gene Chen Signed-off-by: Benson Leung Tested-by: Scot Doyle Reviewed-by: Mika Westerberg Signed-off-by: Olof Johansson --- drivers/platform/chrome/chromeos_laptop.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers/platform/chrome/chromeos_laptop.c') diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c index e0a671075b28..37fa570a7636 100644 --- a/drivers/platform/chrome/chromeos_laptop.c +++ b/drivers/platform/chrome/chromeos_laptop.c @@ -394,6 +394,13 @@ static struct chromeos_laptop dell_chromebook_11 = { }, }; +static struct chromeos_laptop toshiba_cb35 = { + .i2c_peripherals = { + /* Touchpad. */ + { .add = setup_cyapa_tp, I2C_ADAPTER_DESIGNWARE_0 }, + }, +}; + static struct chromeos_laptop acer_c7_chromebook = { .i2c_peripherals = { /* Touchpad. */ @@ -475,6 +482,14 @@ static struct dmi_system_id chromeos_laptop_dmi_table[] __initdata = { }, _CBDD(hp_chromebook_14), }, + { + .ident = "Toshiba CB35", + .matches = { + DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"), + DMI_MATCH(DMI_PRODUCT_NAME, "Leon"), + }, + _CBDD(toshiba_cb35), + }, { .ident = "Acer C7 Chromebook", .matches = { -- cgit v1.2.3-59-g8ed1b From 49c68a21d4f308d67b8a4ff8bcf5cd3af53f027d Mon Sep 17 00:00:00 2001 From: Robin Schroer Date: Thu, 29 May 2014 20:45:07 +0200 Subject: platform/chrome: coding style fixes added blank lines after declarations in some places Signed-off-by: Robin Schroer Signed-off-by: Olof Johansson --- drivers/platform/chrome/chromeos_laptop.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/platform/chrome/chromeos_laptop.c') diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c index 37fa570a7636..a53fe76de5d1 100644 --- a/drivers/platform/chrome/chromeos_laptop.c +++ b/drivers/platform/chrome/chromeos_laptop.c @@ -187,6 +187,7 @@ static int __find_i2c_adap(struct device *dev, void *data) struct i2c_lookup *lookup = data; static const char *prefix = "i2c-"; struct i2c_adapter *adapter; + if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0) return 0; adapter = to_i2c_adapter(dev); @@ -248,6 +249,7 @@ static struct i2c_client *add_i2c_device(const char *name, struct i2c_board_info *info) { const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END }; + return __add_probed_i2c_device(name, find_i2c_adapter_num(type), info, @@ -542,6 +544,7 @@ static struct platform_driver cros_platform_driver = { static int __init chromeos_laptop_init(void) { int ret; + if (!dmi_check_system(chromeos_laptop_dmi_table)) { pr_debug("%s unsupported system.\n", __func__); return -ENODEV; -- cgit v1.2.3-59-g8ed1b From b90b3c4ae06af135e279c9a5aa1c640d22787fc4 Mon Sep 17 00:00:00 2001 From: Michael Mullin Date: Tue, 15 Jul 2014 20:00:54 -0400 Subject: platform/chrome: Add support for the acer c720p touchscreen. Add support for the acer c720p touchscreen. Tested manually by using the touchscreen on the acer c720p-2664 Based on the following patch by Dave Parker : https://chromium-review.googlesource.com/#/c/167136/ Signed-off-by: Michael Mullin Reviewed-by: Benson Leung Signed-off-by: Olof Johansson --- drivers/platform/chrome/chromeos_laptop.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/platform/chrome/chromeos_laptop.c') diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c index a53fe76de5d1..15b1b162890f 100644 --- a/drivers/platform/chrome/chromeos_laptop.c +++ b/drivers/platform/chrome/chromeos_laptop.c @@ -419,6 +419,8 @@ static struct chromeos_laptop acer_ac700 = { static struct chromeos_laptop acer_c720 = { .i2c_peripherals = { + /* Touchscreen. */ + { .add = setup_atmel_1664s_ts, I2C_ADAPTER_DESIGNWARE_1 }, /* Touchpad. */ { .add = setup_cyapa_tp, I2C_ADAPTER_DESIGNWARE_0 }, /* Light Sensor. */ -- cgit v1.2.3-59-g8ed1b From 5502486a2077e4280c618b82e8a77ed35932956f Mon Sep 17 00:00:00 2001 From: Benson Leung Date: Tue, 15 Jul 2014 17:43:11 -0700 Subject: platform/chrome: chromeos_laptop - Add a limit for deferred retries Limit the number of times we allow deferred probing to attempt to add i2c devices. This will help with some device flakiness at probe time. For example, some touchpads and touchscreens may be in transition between bootloader and operational mode and may appear at neither address briefly. Adapters, however, have no limit as it depends on when the i2c adapter driver module is loaded. The module may even be loaded manually by the user using modprobe or insmod. By default, set MAX_I2C_DEVICE_DEFERALS to 5. Based on this patch from the chromeos-kernel : https://chromium-review.googlesource.com/168130 Signed-off-by: Benson Leung Signed-off-by: Olof Johansson --- drivers/platform/chrome/chromeos_laptop.c | 45 ++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'drivers/platform/chrome/chromeos_laptop.c') diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c index 15b1b162890f..6ed6375fe6bf 100644 --- a/drivers/platform/chrome/chromeos_laptop.c +++ b/drivers/platform/chrome/chromeos_laptop.c @@ -37,6 +37,8 @@ #define ISL_ALS_I2C_ADDR 0x44 #define TAOS_ALS_I2C_ADDR 0x29 +#define MAX_I2C_DEVICE_DEFERRALS 5 + static struct i2c_client *als; static struct i2c_client *tp; static struct i2c_client *ts; @@ -58,9 +60,17 @@ enum i2c_adapter_type { I2C_ADAPTER_DESIGNWARE_1, }; +enum i2c_peripheral_state { + UNPROBED = 0, + PROBED, + TIMEDOUT, +}; + struct i2c_peripheral { int (*add)(enum i2c_adapter_type type); enum i2c_adapter_type type; + enum i2c_peripheral_state state; + int tries; }; #define MAX_I2C_PERIPHERALS 3 @@ -166,8 +176,8 @@ static struct i2c_client *__add_probed_i2c_device( /* add the i2c device */ client = i2c_new_probed_device(adapter, info, addrs, NULL); if (!client) - pr_err("%s failed to register device %d-%02x\n", - __func__, bus, info->addr); + pr_notice("%s failed to register device %d-%02x\n", + __func__, bus, info->addr); else pr_debug("%s added i2c device %d-%02x\n", __func__, bus, info->addr); @@ -347,9 +357,36 @@ static int chromeos_laptop_probe(struct platform_device *pdev) if (i2c_dev->add == NULL) break; - /* Add the device. Set -EPROBE_DEFER on any failure */ - if (i2c_dev->add(i2c_dev->type)) + if (i2c_dev->state == TIMEDOUT || i2c_dev->state == PROBED) + continue; + + /* + * Check that the i2c adapter is present. + * -EPROBE_DEFER if missing as the adapter may appear much + * later. + */ + if (find_i2c_adapter_num(i2c_dev->type) == -ENODEV) { ret = -EPROBE_DEFER; + continue; + } + + /* Add the device. */ + if (i2c_dev->add(i2c_dev->type) == -EAGAIN) { + /* + * Set -EPROBE_DEFER a limited num of times + * if device is not successfully added. + */ + if (++i2c_dev->tries < MAX_I2C_DEVICE_DEFERRALS) { + ret = -EPROBE_DEFER; + } else { + /* Ran out of tries. */ + pr_notice("%s: Ran out of tries for device.\n", + __func__); + i2c_dev->state = TIMEDOUT; + } + } else { + i2c_dev->state = PROBED; + } } return ret; -- cgit v1.2.3-59-g8ed1b