aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/chrome/chromeos_laptop.c
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2014-06-17 17:02:00 -0400
committerOlof Johansson <olof@lixom.net>2014-07-10 12:34:48 -0400
commitda3b0ab75aadab63d1ffd5563100c9386e444dad (patch)
tree8eac06c74569bb137d8855e5cdb580029dd47aa7 /drivers/platform/chrome/chromeos_laptop.c
parentcd3de83f147601356395b57a8673e9c5ff1e59d1 (diff)
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 <mika.westerberg@linux.intel.com> Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Benson Leung <bleung@chromium.org> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'drivers/platform/chrome/chromeos_laptop.c')
-rw-r--r--drivers/platform/chrome/chromeos_laptop.c45
1 files changed, 39 insertions, 6 deletions
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[] = {
45 "SMBus I801 adapter", 45 "SMBus I801 adapter",
46 "i915 gmbus vga", 46 "i915 gmbus vga",
47 "i915 gmbus panel", 47 "i915 gmbus panel",
48 "i2c-designware-pci",
49 "i2c-designware-pci",
48}; 50};
49 51
50/* Keep this enum consistent with i2c_adapter_names */ 52/* Keep this enum consistent with i2c_adapter_names */
@@ -52,6 +54,8 @@ enum i2c_adapter_type {
52 I2C_ADAPTER_SMBUS = 0, 54 I2C_ADAPTER_SMBUS = 0,
53 I2C_ADAPTER_VGADDC, 55 I2C_ADAPTER_VGADDC,
54 I2C_ADAPTER_PANEL, 56 I2C_ADAPTER_PANEL,
57 I2C_ADAPTER_DESIGNWARE_0,
58 I2C_ADAPTER_DESIGNWARE_1,
55}; 59};
56 60
57struct i2c_peripheral { 61struct i2c_peripheral {
@@ -172,29 +176,42 @@ static struct i2c_client *__add_probed_i2c_device(
172 return client; 176 return client;
173} 177}
174 178
179struct i2c_lookup {
180 const char *name;
181 int instance;
182 int n;
183};
184
175static int __find_i2c_adap(struct device *dev, void *data) 185static int __find_i2c_adap(struct device *dev, void *data)
176{ 186{
177 const char *name = data; 187 struct i2c_lookup *lookup = data;
178 static const char *prefix = "i2c-"; 188 static const char *prefix = "i2c-";
179 struct i2c_adapter *adapter; 189 struct i2c_adapter *adapter;
180 if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0) 190 if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0)
181 return 0; 191 return 0;
182 adapter = to_i2c_adapter(dev); 192 adapter = to_i2c_adapter(dev);
183 return (strncmp(adapter->name, name, strlen(name)) == 0); 193 if (strncmp(adapter->name, lookup->name, strlen(lookup->name)) == 0 &&
194 lookup->n++ == lookup->instance)
195 return 1;
196 return 0;
184} 197}
185 198
186static int find_i2c_adapter_num(enum i2c_adapter_type type) 199static int find_i2c_adapter_num(enum i2c_adapter_type type)
187{ 200{
188 struct device *dev = NULL; 201 struct device *dev = NULL;
189 struct i2c_adapter *adapter; 202 struct i2c_adapter *adapter;
190 const char *name = i2c_adapter_names[type]; 203 struct i2c_lookup lookup;
204
205 memset(&lookup, 0, sizeof(lookup));
206 lookup.name = i2c_adapter_names[type];
207 lookup.instance = (type == I2C_ADAPTER_DESIGNWARE_1) ? 1 : 0;
208
191 /* find the adapter by name */ 209 /* find the adapter by name */
192 dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, 210 dev = bus_find_device(&i2c_bus_type, NULL, &lookup, __find_i2c_adap);
193 __find_i2c_adap);
194 if (!dev) { 211 if (!dev) {
195 /* Adapters may appear later. Deferred probing will retry */ 212 /* Adapters may appear later. Deferred probing will retry */
196 pr_notice("%s: i2c adapter %s not found on system.\n", __func__, 213 pr_notice("%s: i2c adapter %s not found on system.\n", __func__,
197 name); 214 lookup.name);
198 return -ENODEV; 215 return -ENODEV;
199 } 216 }
200 adapter = to_i2c_adapter(dev); 217 adapter = to_i2c_adapter(dev);
@@ -377,6 +394,15 @@ static struct chromeos_laptop acer_ac700 = {
377 }, 394 },
378}; 395};
379 396
397static struct chromeos_laptop acer_c720 = {
398 .i2c_peripherals = {
399 /* Touchpad. */
400 { .add = setup_cyapa_tp, I2C_ADAPTER_DESIGNWARE_0 },
401 /* Light Sensor. */
402 { .add = setup_isl29018_als, I2C_ADAPTER_DESIGNWARE_1 },
403 },
404};
405
380static struct chromeos_laptop hp_pavilion_14_chromebook = { 406static struct chromeos_laptop hp_pavilion_14_chromebook = {
381 .i2c_peripherals = { 407 .i2c_peripherals = {
382 /* Touchpad. */ 408 /* Touchpad. */
@@ -434,6 +460,13 @@ static struct dmi_system_id chromeos_laptop_dmi_table[] __initdata = {
434 _CBDD(acer_ac700), 460 _CBDD(acer_ac700),
435 }, 461 },
436 { 462 {
463 .ident = "Acer C720",
464 .matches = {
465 DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"),
466 },
467 _CBDD(acer_c720),
468 },
469 {
437 .ident = "HP Pavilion 14 Chromebook", 470 .ident = "HP Pavilion 14 Chromebook",
438 .matches = { 471 .matches = {
439 DMI_MATCH(DMI_PRODUCT_NAME, "Butterfly"), 472 DMI_MATCH(DMI_PRODUCT_NAME, "Butterfly"),