2018-03-21 05:31:28 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
// Driver to instantiate Chromebook i2c/smbus devices.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2012 Google, Inc.
|
|
|
|
// Author: Benson Leung <bleung@chromium.org>
|
2012-10-26 04:21:21 +07:00
|
|
|
|
2018-03-21 05:31:30 +07:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2012-10-26 04:21:21 +07:00
|
|
|
#include <linux/dmi.h>
|
|
|
|
#include <linux/i2c.h>
|
2015-08-05 06:36:29 +07:00
|
|
|
#include <linux/platform_data/atmel_mxt_ts.h>
|
2013-03-08 10:43:34 +07:00
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/interrupt.h>
|
2012-10-26 04:21:21 +07:00
|
|
|
#include <linux/module.h>
|
2013-10-21 10:58:25 +07:00
|
|
|
#include <linux/platform_device.h>
|
2012-10-26 04:21:21 +07:00
|
|
|
|
2013-02-22 03:14:59 +07:00
|
|
|
#define ATMEL_TP_I2C_ADDR 0x4b
|
|
|
|
#define ATMEL_TP_I2C_BL_ADDR 0x25
|
2013-02-22 03:15:00 +07:00
|
|
|
#define ATMEL_TS_I2C_ADDR 0x4a
|
|
|
|
#define ATMEL_TS_I2C_BL_ADDR 0x26
|
2012-10-26 04:21:21 +07:00
|
|
|
#define CYAPA_TP_I2C_ADDR 0x67
|
2016-05-02 07:57:16 +07:00
|
|
|
#define ELAN_TP_I2C_ADDR 0x15
|
2012-10-26 04:21:21 +07:00
|
|
|
#define ISL_ALS_I2C_ADDR 0x44
|
2013-02-02 05:34:45 +07:00
|
|
|
#define TAOS_ALS_I2C_ADDR 0x29
|
2012-10-26 04:21:21 +07:00
|
|
|
|
2014-07-16 07:43:11 +07:00
|
|
|
#define MAX_I2C_DEVICE_DEFERRALS 5
|
|
|
|
|
2013-11-26 04:10:25 +07:00
|
|
|
static const char *i2c_adapter_names[] = {
|
2012-10-26 04:21:21 +07:00
|
|
|
"SMBus I801 adapter",
|
2013-02-22 03:14:55 +07:00
|
|
|
"i915 gmbus vga",
|
|
|
|
"i915 gmbus panel",
|
2015-11-03 18:09:00 +07:00
|
|
|
"Synopsys DesignWare I2C adapter",
|
|
|
|
"Synopsys DesignWare I2C adapter",
|
2012-10-26 04:21:21 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Keep this enum consistent with i2c_adapter_names */
|
|
|
|
enum i2c_adapter_type {
|
|
|
|
I2C_ADAPTER_SMBUS = 0,
|
2013-02-22 03:14:55 +07:00
|
|
|
I2C_ADAPTER_VGADDC,
|
|
|
|
I2C_ADAPTER_PANEL,
|
2014-06-18 04:02:00 +07:00
|
|
|
I2C_ADAPTER_DESIGNWARE_0,
|
|
|
|
I2C_ADAPTER_DESIGNWARE_1,
|
2012-10-26 04:21:21 +07:00
|
|
|
};
|
|
|
|
|
2014-07-16 07:43:11 +07:00
|
|
|
enum i2c_peripheral_state {
|
|
|
|
UNPROBED = 0,
|
|
|
|
PROBED,
|
|
|
|
TIMEDOUT,
|
2018-03-21 05:31:32 +07:00
|
|
|
FAILED,
|
2012-10-26 04:21:21 +07:00
|
|
|
};
|
|
|
|
|
2013-10-21 10:58:24 +07:00
|
|
|
struct i2c_peripheral {
|
2018-03-21 05:31:32 +07:00
|
|
|
struct i2c_board_info board_info;
|
|
|
|
unsigned short alt_addr;
|
|
|
|
const char *dmi_name;
|
2013-10-21 10:58:24 +07:00
|
|
|
enum i2c_adapter_type type;
|
2018-03-21 05:31:32 +07:00
|
|
|
|
2014-07-16 07:43:11 +07:00
|
|
|
enum i2c_peripheral_state state;
|
2018-03-21 05:31:32 +07:00
|
|
|
struct i2c_client *client;
|
2014-07-16 07:43:11 +07:00
|
|
|
int tries;
|
2013-10-21 10:58:24 +07:00
|
|
|
};
|
|
|
|
|
2016-05-02 07:57:16 +07:00
|
|
|
#define MAX_I2C_PERIPHERALS 4
|
2013-10-21 10:58:24 +07:00
|
|
|
|
|
|
|
struct chromeos_laptop {
|
|
|
|
struct i2c_peripheral i2c_peripherals[MAX_I2C_PERIPHERALS];
|
|
|
|
};
|
|
|
|
|
2013-10-21 10:58:25 +07:00
|
|
|
static struct chromeos_laptop *cros_laptop;
|
|
|
|
|
2018-03-21 05:31:32 +07:00
|
|
|
static struct i2c_client *
|
|
|
|
chromes_laptop_instantiate_i2c_device(int bus,
|
|
|
|
struct i2c_board_info *info,
|
|
|
|
unsigned short alt_addr)
|
2012-10-26 04:21:21 +07:00
|
|
|
{
|
|
|
|
struct i2c_adapter *adapter;
|
2015-04-15 03:50:09 +07:00
|
|
|
struct i2c_client *client = NULL;
|
|
|
|
const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END };
|
2012-10-26 04:21:21 +07:00
|
|
|
|
|
|
|
adapter = i2c_get_adapter(bus);
|
|
|
|
if (!adapter) {
|
2018-03-21 05:31:30 +07:00
|
|
|
pr_err("failed to get i2c adapter %d\n", bus);
|
2012-10-26 04:21:21 +07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:50:09 +07:00
|
|
|
/*
|
|
|
|
* Add the i2c device. If we can't detect it at the primary
|
|
|
|
* address we scan secondary addresses. In any case the client
|
|
|
|
* structure gets assigned primary address.
|
|
|
|
*/
|
|
|
|
client = i2c_new_probed_device(adapter, info, addr_list, NULL);
|
2018-03-21 05:31:32 +07:00
|
|
|
if (!client && alt_addr) {
|
2015-04-15 03:50:09 +07:00
|
|
|
struct i2c_board_info dummy_info = {
|
|
|
|
I2C_BOARD_INFO("dummy", info->addr),
|
|
|
|
};
|
2018-03-21 05:31:32 +07:00
|
|
|
const unsigned short alt_addr_list[] = {
|
|
|
|
alt_addr, I2C_CLIENT_END
|
|
|
|
};
|
2015-04-15 03:50:09 +07:00
|
|
|
struct i2c_client *dummy;
|
|
|
|
|
|
|
|
dummy = i2c_new_probed_device(adapter, &dummy_info,
|
|
|
|
alt_addr_list, NULL);
|
|
|
|
if (dummy) {
|
2018-03-21 05:31:30 +07:00
|
|
|
pr_debug("%d-%02x is probed at %02x\n",
|
|
|
|
bus, info->addr, dummy->addr);
|
2015-04-15 03:50:09 +07:00
|
|
|
i2c_unregister_device(dummy);
|
|
|
|
client = i2c_new_device(adapter, info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-26 04:21:21 +07:00
|
|
|
if (!client)
|
2018-03-21 05:31:30 +07:00
|
|
|
pr_notice("failed to register device %d-%02x\n",
|
|
|
|
bus, info->addr);
|
2012-10-26 04:21:21 +07:00
|
|
|
else
|
2018-03-21 05:31:30 +07:00
|
|
|
pr_debug("added i2c device %d-%02x\n", bus, info->addr);
|
2012-10-26 04:21:21 +07:00
|
|
|
|
|
|
|
i2c_put_adapter(adapter);
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
|
2014-06-18 04:02:00 +07:00
|
|
|
struct i2c_lookup {
|
|
|
|
const char *name;
|
|
|
|
int instance;
|
|
|
|
int n;
|
|
|
|
};
|
|
|
|
|
2013-10-21 10:58:25 +07:00
|
|
|
static int __find_i2c_adap(struct device *dev, void *data)
|
2012-10-26 04:21:21 +07:00
|
|
|
{
|
2014-06-18 04:02:00 +07:00
|
|
|
struct i2c_lookup *lookup = data;
|
2012-10-26 04:21:21 +07:00
|
|
|
static const char *prefix = "i2c-";
|
|
|
|
struct i2c_adapter *adapter;
|
2014-05-30 01:45:07 +07:00
|
|
|
|
2012-10-26 04:21:21 +07:00
|
|
|
if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0)
|
|
|
|
return 0;
|
|
|
|
adapter = to_i2c_adapter(dev);
|
2014-06-18 04:02:00 +07:00
|
|
|
if (strncmp(adapter->name, lookup->name, strlen(lookup->name)) == 0 &&
|
|
|
|
lookup->n++ == lookup->instance)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
2012-10-26 04:21:21 +07:00
|
|
|
}
|
|
|
|
|
2013-10-21 10:58:25 +07:00
|
|
|
static int find_i2c_adapter_num(enum i2c_adapter_type type)
|
2012-10-26 04:21:21 +07:00
|
|
|
{
|
|
|
|
struct device *dev = NULL;
|
|
|
|
struct i2c_adapter *adapter;
|
2014-06-18 04:02:00 +07:00
|
|
|
struct i2c_lookup lookup;
|
|
|
|
|
|
|
|
memset(&lookup, 0, sizeof(lookup));
|
|
|
|
lookup.name = i2c_adapter_names[type];
|
|
|
|
lookup.instance = (type == I2C_ADAPTER_DESIGNWARE_1) ? 1 : 0;
|
|
|
|
|
2012-10-26 04:21:21 +07:00
|
|
|
/* find the adapter by name */
|
2014-06-18 04:02:00 +07:00
|
|
|
dev = bus_find_device(&i2c_bus_type, NULL, &lookup, __find_i2c_adap);
|
2012-10-26 04:21:21 +07:00
|
|
|
if (!dev) {
|
2013-10-21 10:58:25 +07:00
|
|
|
/* Adapters may appear later. Deferred probing will retry */
|
2018-03-21 05:31:30 +07:00
|
|
|
pr_notice("i2c adapter %s not found on system.\n",
|
2014-06-18 04:02:00 +07:00
|
|
|
lookup.name);
|
2012-10-26 04:21:21 +07:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
adapter = to_i2c_adapter(dev);
|
|
|
|
return adapter->nr;
|
|
|
|
}
|
|
|
|
|
2018-03-21 05:31:32 +07:00
|
|
|
static int chromeos_laptop_add_peripheral(struct i2c_peripheral *i2c_dev)
|
2013-02-22 03:14:58 +07:00
|
|
|
{
|
2018-03-21 05:31:32 +07:00
|
|
|
struct i2c_client *client;
|
|
|
|
int bus;
|
2013-02-22 03:14:58 +07:00
|
|
|
|
2018-03-21 05:31:32 +07:00
|
|
|
/*
|
|
|
|
* Check that the i2c adapter is present.
|
|
|
|
* -EPROBE_DEFER if missing as the adapter may appear much
|
|
|
|
* later.
|
|
|
|
*/
|
|
|
|
bus = find_i2c_adapter_num(i2c_dev->type);
|
|
|
|
if (bus < 0)
|
|
|
|
return bus == -ENODEV ? -EPROBE_DEFER : bus;
|
2013-10-21 10:58:25 +07:00
|
|
|
|
2018-03-21 05:31:32 +07:00
|
|
|
client = chromes_laptop_instantiate_i2c_device(bus,
|
|
|
|
&i2c_dev->board_info,
|
|
|
|
i2c_dev->alt_addr);
|
|
|
|
if (!client) {
|
|
|
|
/*
|
|
|
|
* Set -EPROBE_DEFER a limited num of times
|
|
|
|
* if device is not successfully added.
|
|
|
|
*/
|
|
|
|
if (++i2c_dev->tries < MAX_I2C_DEVICE_DEFERRALS) {
|
|
|
|
return -EPROBE_DEFER;
|
|
|
|
} else {
|
|
|
|
/* Ran out of tries. */
|
|
|
|
pr_notice("ran out of tries for device.\n");
|
|
|
|
i2c_dev->state = TIMEDOUT;
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
2013-02-22 03:14:57 +07:00
|
|
|
|
2018-03-21 05:31:32 +07:00
|
|
|
i2c_dev->client = client;
|
|
|
|
i2c_dev->state = PROBED;
|
2013-10-21 10:58:25 +07:00
|
|
|
|
2018-03-21 05:31:32 +07:00
|
|
|
return 0;
|
2013-02-02 05:34:46 +07:00
|
|
|
}
|
|
|
|
|
2013-10-21 10:58:25 +07:00
|
|
|
static int chromeos_laptop_probe(struct platform_device *pdev)
|
|
|
|
{
|
2018-03-21 05:31:32 +07:00
|
|
|
struct i2c_peripheral *i2c_dev;
|
2013-10-21 10:58:25 +07:00
|
|
|
int i;
|
|
|
|
int ret = 0;
|
2013-10-21 10:58:24 +07:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_I2C_PERIPHERALS; i++) {
|
|
|
|
i2c_dev = &cros_laptop->i2c_peripherals[i];
|
|
|
|
|
|
|
|
/* No more peripherals. */
|
2018-03-21 05:31:32 +07:00
|
|
|
if (!i2c_dev->board_info.addr)
|
2013-10-21 10:58:24 +07:00
|
|
|
break;
|
|
|
|
|
2018-03-21 05:31:32 +07:00
|
|
|
if (i2c_dev->state != UNPROBED)
|
2014-07-16 07:43:11 +07:00
|
|
|
continue;
|
|
|
|
|
2018-03-21 05:31:32 +07:00
|
|
|
if (chromeos_laptop_add_peripheral(i2c_dev) == -EPROBE_DEFER)
|
2013-10-21 10:58:25 +07:00
|
|
|
ret = -EPROBE_DEFER;
|
2013-10-21 10:58:24 +07:00
|
|
|
}
|
|
|
|
|
2013-10-21 10:58:25 +07:00
|
|
|
return ret;
|
2013-02-02 05:34:45 +07:00
|
|
|
}
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop samsung_series_5_550 = {
|
2013-10-21 10:58:24 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Touchpad. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR),
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_SMBUS,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
/* Light Sensor. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("isl29018", ISL_ALS_I2C_ADDR),
|
|
|
|
},
|
|
|
|
.dmi_name = "lightsensor",
|
|
|
|
.type = I2C_ADAPTER_SMBUS,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop samsung_series_5 = {
|
2013-10-21 10:58:24 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Light Sensor. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("tsl2583", TAOS_ALS_I2C_ADDR),
|
|
|
|
},
|
|
|
|
.type = I2C_ADAPTER_SMBUS,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-21 05:31:32 +07:00
|
|
|
static struct mxt_platform_data atmel_1664s_platform_data = {
|
|
|
|
.irqflags = IRQF_TRIGGER_FALLING,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int chromebook_pixel_tp_keys[] = {
|
|
|
|
KEY_RESERVED,
|
|
|
|
KEY_RESERVED,
|
|
|
|
KEY_RESERVED,
|
|
|
|
KEY_RESERVED,
|
|
|
|
KEY_RESERVED,
|
|
|
|
BTN_LEFT
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct mxt_platform_data chromebook_pixel_tp_platform_data = {
|
|
|
|
.irqflags = IRQF_TRIGGER_FALLING,
|
|
|
|
.t19_num_keys = ARRAY_SIZE(chromebook_pixel_tp_keys),
|
|
|
|
.t19_keymap = chromebook_pixel_tp_keys,
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop chromebook_pixel = {
|
2013-10-21 10:58:24 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Touch Screen. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("atmel_mxt_ts",
|
|
|
|
ATMEL_TS_I2C_ADDR),
|
|
|
|
.platform_data = &atmel_1664s_platform_data,
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "touchscreen",
|
|
|
|
.type = I2C_ADAPTER_PANEL,
|
|
|
|
.alt_addr = ATMEL_TS_I2C_BL_ADDR,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
/* Touchpad. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("atmel_mxt_tp",
|
|
|
|
ATMEL_TP_I2C_ADDR),
|
|
|
|
.platform_data =
|
|
|
|
&chromebook_pixel_tp_platform_data,
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_VGADDC,
|
|
|
|
.alt_addr = ATMEL_TP_I2C_BL_ADDR,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
/* Light Sensor. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("isl29018", ISL_ALS_I2C_ADDR),
|
|
|
|
},
|
|
|
|
.dmi_name = "lightsensor",
|
|
|
|
.type = I2C_ADAPTER_PANEL,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop hp_chromebook_14 = {
|
2014-06-18 04:02:01 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Touchpad. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR),
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_DESIGNWARE_0,
|
|
|
|
},
|
2014-06-18 04:02:01 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop dell_chromebook_11 = {
|
2014-06-18 04:02:02 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Touchpad. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR),
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_DESIGNWARE_0,
|
|
|
|
},
|
2016-05-02 07:57:17 +07:00
|
|
|
/* Elan Touchpad option. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("elan_i2c", ELAN_TP_I2C_ADDR),
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_DESIGNWARE_0,
|
|
|
|
},
|
2014-06-18 04:02:02 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop toshiba_cb35 = {
|
2014-06-18 04:02:03 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Touchpad. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR),
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_DESIGNWARE_0,
|
|
|
|
},
|
2014-06-18 04:02:03 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop acer_c7_chromebook = {
|
2013-10-21 10:58:24 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Touchpad. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR),
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_SMBUS,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop acer_ac700 = {
|
2013-10-21 10:58:24 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Light Sensor. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("tsl2583", TAOS_ALS_I2C_ADDR),
|
|
|
|
},
|
|
|
|
.type = I2C_ADAPTER_SMBUS,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop acer_c720 = {
|
2014-06-18 04:02:00 +07:00
|
|
|
.i2c_peripherals = {
|
2014-07-16 07:00:54 +07:00
|
|
|
/* Touchscreen. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("atmel_mxt_ts",
|
|
|
|
ATMEL_TS_I2C_ADDR),
|
|
|
|
.platform_data = &atmel_1664s_platform_data,
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "touchscreen",
|
|
|
|
.type = I2C_ADAPTER_DESIGNWARE_1,
|
|
|
|
.alt_addr = ATMEL_TS_I2C_BL_ADDR,
|
|
|
|
},
|
2014-06-18 04:02:00 +07:00
|
|
|
/* Touchpad. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR),
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_DESIGNWARE_0,
|
|
|
|
},
|
2016-05-02 07:57:16 +07:00
|
|
|
/* Elan Touchpad option. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("elan_i2c", ELAN_TP_I2C_ADDR),
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_DESIGNWARE_0,
|
|
|
|
},
|
2014-06-18 04:02:00 +07:00
|
|
|
/* Light Sensor. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("isl29018", ISL_ALS_I2C_ADDR),
|
|
|
|
},
|
|
|
|
.dmi_name = "lightsensor",
|
|
|
|
.type = I2C_ADAPTER_DESIGNWARE_1,
|
|
|
|
},
|
2014-06-18 04:02:00 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop hp_pavilion_14_chromebook = {
|
2013-10-21 10:58:24 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Touchpad. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR),
|
|
|
|
.flags = I2C_CLIENT_WAKE,
|
|
|
|
},
|
|
|
|
.dmi_name = "trackpad",
|
|
|
|
.type = I2C_ADAPTER_SMBUS,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:59:15 +07:00
|
|
|
static struct chromeos_laptop cr48 = {
|
2013-10-21 10:58:24 +07:00
|
|
|
.i2c_peripherals = {
|
|
|
|
/* Light Sensor. */
|
2018-03-21 05:31:32 +07:00
|
|
|
{
|
|
|
|
.board_info = {
|
|
|
|
I2C_BOARD_INFO("tsl2563", TAOS_ALS_I2C_ADDR),
|
|
|
|
},
|
|
|
|
.type = I2C_ADAPTER_SMBUS,
|
|
|
|
},
|
2013-10-21 10:58:24 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2017-09-14 16:59:30 +07:00
|
|
|
static const struct dmi_system_id chromeos_laptop_dmi_table[] __initconst = {
|
2012-10-26 04:21:21 +07:00
|
|
|
{
|
2013-10-21 10:58:24 +07:00
|
|
|
.ident = "Samsung Series 5 550",
|
2012-10-26 04:21:21 +07:00
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"),
|
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&samsung_series_5_550,
|
2013-02-22 03:14:59 +07:00
|
|
|
},
|
2012-10-26 04:21:21 +07:00
|
|
|
{
|
2013-10-21 10:58:24 +07:00
|
|
|
.ident = "Samsung Series 5",
|
2012-10-26 04:21:21 +07:00
|
|
|
.matches = {
|
2013-10-21 10:58:24 +07:00
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Alex"),
|
2012-10-26 04:21:21 +07:00
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&samsung_series_5,
|
2012-10-26 04:21:21 +07:00
|
|
|
},
|
2013-02-22 03:14:57 +07:00
|
|
|
{
|
2013-10-21 10:58:24 +07:00
|
|
|
.ident = "Chromebook Pixel",
|
2013-02-22 03:14:57 +07:00
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Link"),
|
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&chromebook_pixel,
|
2013-02-22 03:14:57 +07:00
|
|
|
},
|
2014-06-18 04:02:02 +07:00
|
|
|
{
|
|
|
|
.ident = "Wolf",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Wolf"),
|
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&dell_chromebook_11,
|
2014-06-18 04:02:02 +07:00
|
|
|
},
|
2014-06-18 04:02:01 +07:00
|
|
|
{
|
|
|
|
.ident = "HP Chromebook 14",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Falco"),
|
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&hp_chromebook_14,
|
2014-06-18 04:02:01 +07:00
|
|
|
},
|
2014-06-18 04:02:03 +07:00
|
|
|
{
|
|
|
|
.ident = "Toshiba CB35",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Leon"),
|
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&toshiba_cb35,
|
2014-06-18 04:02:03 +07:00
|
|
|
},
|
2013-02-02 05:34:44 +07:00
|
|
|
{
|
2013-10-21 10:58:24 +07:00
|
|
|
.ident = "Acer C7 Chromebook",
|
2013-02-02 05:34:44 +07:00
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Parrot"),
|
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&acer_c7_chromebook,
|
2013-02-11 07:20:17 +07:00
|
|
|
},
|
|
|
|
{
|
2013-10-21 10:58:24 +07:00
|
|
|
.ident = "Acer AC700",
|
2013-02-11 07:20:17 +07:00
|
|
|
.matches = {
|
2013-10-21 10:58:24 +07:00
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
|
2013-02-11 07:20:17 +07:00
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&acer_ac700,
|
2013-02-02 05:34:44 +07:00
|
|
|
},
|
2014-06-18 04:02:00 +07:00
|
|
|
{
|
|
|
|
.ident = "Acer C720",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"),
|
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&acer_c720,
|
2014-06-18 04:02:00 +07:00
|
|
|
},
|
2013-02-02 05:34:46 +07:00
|
|
|
{
|
2013-10-21 10:58:24 +07:00
|
|
|
.ident = "HP Pavilion 14 Chromebook",
|
2013-02-02 05:34:46 +07:00
|
|
|
.matches = {
|
2013-10-21 10:58:24 +07:00
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Butterfly"),
|
2013-02-02 05:34:46 +07:00
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&hp_pavilion_14_chromebook,
|
2013-02-02 05:34:46 +07:00
|
|
|
},
|
2013-02-02 05:34:45 +07:00
|
|
|
{
|
2013-10-21 10:58:24 +07:00
|
|
|
.ident = "Cr-48",
|
2013-02-02 05:34:45 +07:00
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Mario"),
|
|
|
|
},
|
2018-03-21 05:31:33 +07:00
|
|
|
.driver_data = (void *)&cr48,
|
2013-02-02 05:34:45 +07:00
|
|
|
},
|
2012-10-26 04:21:21 +07:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(dmi, chromeos_laptop_dmi_table);
|
|
|
|
|
2013-10-21 10:58:25 +07:00
|
|
|
static struct platform_device *cros_platform_device;
|
|
|
|
|
|
|
|
static struct platform_driver cros_platform_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "chromeos_laptop",
|
|
|
|
},
|
|
|
|
.probe = chromeos_laptop_probe,
|
|
|
|
};
|
|
|
|
|
2018-03-21 05:31:33 +07:00
|
|
|
static int __init chromeos_laptop_get_irq_from_dmi(const char *dmi_name)
|
|
|
|
{
|
|
|
|
const struct dmi_device *dmi_dev;
|
|
|
|
const struct dmi_dev_onboard *dev_data;
|
|
|
|
|
|
|
|
dmi_dev = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD, dmi_name, NULL);
|
|
|
|
if (!dmi_dev) {
|
|
|
|
pr_err("failed to find DMI device '%s'\n", dmi_name);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_data = dmi_dev->device_data;
|
|
|
|
if (!dev_data) {
|
|
|
|
pr_err("failed to get data from DMI for '%s'\n", dmi_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dev_data->instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct chromeos_laptop * __init
|
|
|
|
chromeos_laptop_prepare(const struct dmi_system_id *id)
|
|
|
|
{
|
|
|
|
struct i2c_peripheral *i2c_dev;
|
|
|
|
int irq;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
cros_laptop = (void *)id->driver_data;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_I2C_PERIPHERALS; i++) {
|
|
|
|
i2c_dev = &cros_laptop->i2c_peripherals[i];
|
|
|
|
|
|
|
|
if (!i2c_dev->dmi_name)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
irq = chromeos_laptop_get_irq_from_dmi(i2c_dev->dmi_name);
|
|
|
|
if (irq < 0)
|
|
|
|
return ERR_PTR(irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cros_laptop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-26 04:21:21 +07:00
|
|
|
static int __init chromeos_laptop_init(void)
|
|
|
|
{
|
2018-03-21 05:31:33 +07:00
|
|
|
const struct dmi_system_id *dmi_id;
|
2013-10-21 10:58:25 +07:00
|
|
|
int ret;
|
2014-05-30 01:45:07 +07:00
|
|
|
|
2018-03-21 05:31:33 +07:00
|
|
|
dmi_id = dmi_first_match(chromeos_laptop_dmi_table);
|
|
|
|
if (!dmi_id) {
|
2018-03-21 05:31:30 +07:00
|
|
|
pr_debug("unsupported system\n");
|
2012-10-26 04:21:21 +07:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
2013-10-21 10:58:25 +07:00
|
|
|
|
2018-03-21 05:31:33 +07:00
|
|
|
pr_debug("DMI Matched %s\n", dmi_id->ident);
|
|
|
|
|
|
|
|
cros_laptop = chromeos_laptop_prepare(dmi_id->driver_data);
|
|
|
|
if (IS_ERR(cros_laptop))
|
|
|
|
return PTR_ERR(cros_laptop);
|
|
|
|
|
2013-10-21 10:58:25 +07:00
|
|
|
ret = platform_driver_register(&cros_platform_driver);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
cros_platform_device = platform_device_alloc("chromeos_laptop", -1);
|
|
|
|
if (!cros_platform_device) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail_platform_device1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = platform_device_add(cros_platform_device);
|
|
|
|
if (ret)
|
|
|
|
goto fail_platform_device2;
|
|
|
|
|
2012-10-26 04:21:21 +07:00
|
|
|
return 0;
|
2013-10-21 10:58:25 +07:00
|
|
|
|
|
|
|
fail_platform_device2:
|
|
|
|
platform_device_put(cros_platform_device);
|
|
|
|
fail_platform_device1:
|
|
|
|
platform_driver_unregister(&cros_platform_driver);
|
|
|
|
return ret;
|
2012-10-26 04:21:21 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit chromeos_laptop_exit(void)
|
|
|
|
{
|
2018-03-21 05:31:32 +07:00
|
|
|
struct i2c_peripheral *i2c_dev;
|
|
|
|
int i;
|
2013-11-27 10:34:58 +07:00
|
|
|
|
|
|
|
platform_device_unregister(cros_platform_device);
|
|
|
|
platform_driver_unregister(&cros_platform_driver);
|
2018-03-21 05:31:32 +07:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_I2C_PERIPHERALS; i++) {
|
|
|
|
i2c_dev = &cros_laptop->i2c_peripherals[i];
|
|
|
|
|
|
|
|
/* No more peripherals */
|
|
|
|
if (!i2c_dev->board_info.type)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i2c_dev->state == PROBED)
|
|
|
|
i2c_unregister_device(i2c_dev->client);
|
|
|
|
}
|
2012-10-26 04:21:21 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(chromeos_laptop_init);
|
|
|
|
module_exit(chromeos_laptop_exit);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Chrome OS Laptop driver");
|
|
|
|
MODULE_AUTHOR("Benson Leung <bleung@chromium.org>");
|
|
|
|
MODULE_LICENSE("GPL");
|