Dmitry Torokhov | 203e0ba | 2018-03-20 15:31:28 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | // Driver to instantiate Chromebook i2c/smbus devices. |
| 3 | // |
| 4 | // Copyright (C) 2012 Google, Inc. |
| 5 | // Author: Benson Leung <bleung@chromium.org> |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 6 | |
Dmitry Torokhov | 4f27f67 | 2018-03-20 15:31:30 -0700 | [diff] [blame] | 7 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 8 | |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 9 | #include <linux/dmi.h> |
| 10 | #include <linux/i2c.h> |
Nick Dyer | 7f3884f7 | 2015-08-04 16:36:29 -0700 | [diff] [blame] | 11 | #include <linux/platform_data/atmel_mxt_ts.h> |
Benson Leung | 2ef3920 | 2013-03-07 19:43:34 -0800 | [diff] [blame] | 12 | #include <linux/input.h> |
| 13 | #include <linux/interrupt.h> |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 15 | #include <linux/platform_device.h> |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 16 | |
Benson Leung | 8e1ad4c | 2013-02-21 12:14:59 -0800 | [diff] [blame] | 17 | #define ATMEL_TP_I2C_ADDR 0x4b |
| 18 | #define ATMEL_TP_I2C_BL_ADDR 0x25 |
Yufeng Shen | 33a84f8 | 2013-02-21 12:15:00 -0800 | [diff] [blame] | 19 | #define ATMEL_TS_I2C_ADDR 0x4a |
| 20 | #define ATMEL_TS_I2C_BL_ADDR 0x26 |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 21 | #define CYAPA_TP_I2C_ADDR 0x67 |
Benson Leung | 9bd9a90 | 2016-05-02 08:57:16 +0800 | [diff] [blame] | 22 | #define ELAN_TP_I2C_ADDR 0x15 |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 23 | #define ISL_ALS_I2C_ADDR 0x44 |
Benson Leung | aabf3f4 | 2013-02-01 14:34:45 -0800 | [diff] [blame] | 24 | #define TAOS_ALS_I2C_ADDR 0x29 |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 25 | |
Benson Leung | 5502486 | 2014-07-15 17:43:11 -0700 | [diff] [blame] | 26 | #define MAX_I2C_DEVICE_DEFERRALS 5 |
| 27 | |
Olof Johansson | 6d3c1af | 2013-11-25 13:10:25 -0800 | [diff] [blame] | 28 | static const char *i2c_adapter_names[] = { |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 29 | "SMBus I801 adapter", |
Benson Leung | 741bf0c | 2013-02-21 12:14:55 -0800 | [diff] [blame] | 30 | "i915 gmbus vga", |
| 31 | "i915 gmbus panel", |
Jarkko Nikula | ebaf31c | 2015-11-03 13:09:00 +0200 | [diff] [blame] | 32 | "Synopsys DesignWare I2C adapter", |
| 33 | "Synopsys DesignWare I2C adapter", |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | /* Keep this enum consistent with i2c_adapter_names */ |
| 37 | enum i2c_adapter_type { |
| 38 | I2C_ADAPTER_SMBUS = 0, |
Benson Leung | 741bf0c | 2013-02-21 12:14:55 -0800 | [diff] [blame] | 39 | I2C_ADAPTER_VGADDC, |
| 40 | I2C_ADAPTER_PANEL, |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 41 | I2C_ADAPTER_DESIGNWARE_0, |
| 42 | I2C_ADAPTER_DESIGNWARE_1, |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
Benson Leung | 5502486 | 2014-07-15 17:43:11 -0700 | [diff] [blame] | 45 | enum i2c_peripheral_state { |
| 46 | UNPROBED = 0, |
| 47 | PROBED, |
| 48 | TIMEDOUT, |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 49 | FAILED, |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 52 | struct i2c_peripheral { |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 53 | struct i2c_board_info board_info; |
| 54 | unsigned short alt_addr; |
| 55 | const char *dmi_name; |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 56 | enum i2c_adapter_type type; |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 57 | |
Benson Leung | 5502486 | 2014-07-15 17:43:11 -0700 | [diff] [blame] | 58 | enum i2c_peripheral_state state; |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 59 | struct i2c_client *client; |
Benson Leung | 5502486 | 2014-07-15 17:43:11 -0700 | [diff] [blame] | 60 | int tries; |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Benson Leung | 9bd9a90 | 2016-05-02 08:57:16 +0800 | [diff] [blame] | 63 | #define MAX_I2C_PERIPHERALS 4 |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 64 | |
| 65 | struct chromeos_laptop { |
| 66 | struct i2c_peripheral i2c_peripherals[MAX_I2C_PERIPHERALS]; |
| 67 | }; |
| 68 | |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 69 | static struct chromeos_laptop *cros_laptop; |
| 70 | |
Dmitry Torokhov | ab6c560 | 2018-03-20 15:31:31 -0700 | [diff] [blame] | 71 | static int chromeos_laptop_get_irq_from_dmi(const char *dmi_name) |
| 72 | { |
| 73 | const struct dmi_device *dmi_dev; |
| 74 | const struct dmi_dev_onboard *dev_data; |
| 75 | |
| 76 | dmi_dev = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD, dmi_name, NULL); |
| 77 | if (!dmi_dev) { |
| 78 | pr_err("failed to find DMI device '%s'\n", dmi_name); |
| 79 | return -ENOENT; |
| 80 | } |
| 81 | |
| 82 | dev_data = dmi_dev->device_data; |
| 83 | if (!dev_data) { |
| 84 | pr_err("failed to get data from DMI for '%s'\n", dmi_name); |
| 85 | return -EINVAL; |
| 86 | } |
| 87 | |
| 88 | return dev_data->instance; |
| 89 | } |
| 90 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 91 | static struct i2c_client * |
| 92 | chromes_laptop_instantiate_i2c_device(int bus, |
| 93 | struct i2c_board_info *info, |
| 94 | unsigned short alt_addr) |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 95 | { |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 96 | struct i2c_adapter *adapter; |
Dmitry Torokhov | 96cba9b | 2015-04-14 13:50:09 -0700 | [diff] [blame] | 97 | struct i2c_client *client = NULL; |
| 98 | const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END }; |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 99 | |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 100 | adapter = i2c_get_adapter(bus); |
| 101 | if (!adapter) { |
Dmitry Torokhov | 4f27f67 | 2018-03-20 15:31:30 -0700 | [diff] [blame] | 102 | pr_err("failed to get i2c adapter %d\n", bus); |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 103 | return NULL; |
| 104 | } |
| 105 | |
Dmitry Torokhov | 96cba9b | 2015-04-14 13:50:09 -0700 | [diff] [blame] | 106 | /* |
| 107 | * Add the i2c device. If we can't detect it at the primary |
| 108 | * address we scan secondary addresses. In any case the client |
| 109 | * structure gets assigned primary address. |
| 110 | */ |
| 111 | client = i2c_new_probed_device(adapter, info, addr_list, NULL); |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 112 | if (!client && alt_addr) { |
Dmitry Torokhov | 96cba9b | 2015-04-14 13:50:09 -0700 | [diff] [blame] | 113 | struct i2c_board_info dummy_info = { |
| 114 | I2C_BOARD_INFO("dummy", info->addr), |
| 115 | }; |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 116 | const unsigned short alt_addr_list[] = { |
| 117 | alt_addr, I2C_CLIENT_END |
| 118 | }; |
Dmitry Torokhov | 96cba9b | 2015-04-14 13:50:09 -0700 | [diff] [blame] | 119 | struct i2c_client *dummy; |
| 120 | |
| 121 | dummy = i2c_new_probed_device(adapter, &dummy_info, |
| 122 | alt_addr_list, NULL); |
| 123 | if (dummy) { |
Dmitry Torokhov | 4f27f67 | 2018-03-20 15:31:30 -0700 | [diff] [blame] | 124 | pr_debug("%d-%02x is probed at %02x\n", |
| 125 | bus, info->addr, dummy->addr); |
Dmitry Torokhov | 96cba9b | 2015-04-14 13:50:09 -0700 | [diff] [blame] | 126 | i2c_unregister_device(dummy); |
| 127 | client = i2c_new_device(adapter, info); |
| 128 | } |
| 129 | } |
| 130 | |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 131 | if (!client) |
Dmitry Torokhov | 4f27f67 | 2018-03-20 15:31:30 -0700 | [diff] [blame] | 132 | pr_notice("failed to register device %d-%02x\n", |
| 133 | bus, info->addr); |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 134 | else |
Dmitry Torokhov | 4f27f67 | 2018-03-20 15:31:30 -0700 | [diff] [blame] | 135 | pr_debug("added i2c device %d-%02x\n", bus, info->addr); |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 136 | |
| 137 | i2c_put_adapter(adapter); |
| 138 | return client; |
| 139 | } |
| 140 | |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 141 | struct i2c_lookup { |
| 142 | const char *name; |
| 143 | int instance; |
| 144 | int n; |
| 145 | }; |
| 146 | |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 147 | static int __find_i2c_adap(struct device *dev, void *data) |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 148 | { |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 149 | struct i2c_lookup *lookup = data; |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 150 | static const char *prefix = "i2c-"; |
| 151 | struct i2c_adapter *adapter; |
Robin Schroer | 49c68a2 | 2014-05-29 20:45:07 +0200 | [diff] [blame] | 152 | |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 153 | if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0) |
| 154 | return 0; |
| 155 | adapter = to_i2c_adapter(dev); |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 156 | if (strncmp(adapter->name, lookup->name, strlen(lookup->name)) == 0 && |
| 157 | lookup->n++ == lookup->instance) |
| 158 | return 1; |
| 159 | return 0; |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 162 | static int find_i2c_adapter_num(enum i2c_adapter_type type) |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 163 | { |
| 164 | struct device *dev = NULL; |
| 165 | struct i2c_adapter *adapter; |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 166 | struct i2c_lookup lookup; |
| 167 | |
| 168 | memset(&lookup, 0, sizeof(lookup)); |
| 169 | lookup.name = i2c_adapter_names[type]; |
| 170 | lookup.instance = (type == I2C_ADAPTER_DESIGNWARE_1) ? 1 : 0; |
| 171 | |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 172 | /* find the adapter by name */ |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 173 | dev = bus_find_device(&i2c_bus_type, NULL, &lookup, __find_i2c_adap); |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 174 | if (!dev) { |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 175 | /* Adapters may appear later. Deferred probing will retry */ |
Dmitry Torokhov | 4f27f67 | 2018-03-20 15:31:30 -0700 | [diff] [blame] | 176 | pr_notice("i2c adapter %s not found on system.\n", |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 177 | lookup.name); |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 178 | return -ENODEV; |
| 179 | } |
| 180 | adapter = to_i2c_adapter(dev); |
| 181 | return adapter->nr; |
| 182 | } |
| 183 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 184 | static int chromeos_laptop_add_peripheral(struct i2c_peripheral *i2c_dev) |
Benson Leung | bcaf089 | 2013-02-21 12:14:58 -0800 | [diff] [blame] | 185 | { |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 186 | struct i2c_client *client; |
| 187 | int bus; |
| 188 | int irq; |
Benson Leung | bcaf089 | 2013-02-21 12:14:58 -0800 | [diff] [blame] | 189 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 190 | /* |
| 191 | * Check that the i2c adapter is present. |
| 192 | * -EPROBE_DEFER if missing as the adapter may appear much |
| 193 | * later. |
| 194 | */ |
| 195 | bus = find_i2c_adapter_num(i2c_dev->type); |
| 196 | if (bus < 0) |
| 197 | return bus == -ENODEV ? -EPROBE_DEFER : bus; |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 198 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 199 | if (i2c_dev->dmi_name) { |
| 200 | irq = chromeos_laptop_get_irq_from_dmi(i2c_dev->dmi_name); |
| 201 | if (irq < 0) { |
| 202 | i2c_dev->state = FAILED; |
| 203 | return irq; |
| 204 | } |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 205 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 206 | i2c_dev->board_info.irq = irq; |
| 207 | } |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 208 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 209 | client = chromes_laptop_instantiate_i2c_device(bus, |
| 210 | &i2c_dev->board_info, |
| 211 | i2c_dev->alt_addr); |
| 212 | if (!client) { |
| 213 | /* |
| 214 | * Set -EPROBE_DEFER a limited num of times |
| 215 | * if device is not successfully added. |
| 216 | */ |
| 217 | if (++i2c_dev->tries < MAX_I2C_DEVICE_DEFERRALS) { |
| 218 | return -EPROBE_DEFER; |
| 219 | } else { |
| 220 | /* Ran out of tries. */ |
| 221 | pr_notice("ran out of tries for device.\n"); |
| 222 | i2c_dev->state = TIMEDOUT; |
| 223 | return -EIO; |
| 224 | } |
| 225 | } |
Benson Leung | 8e1ad4c | 2013-02-21 12:14:59 -0800 | [diff] [blame] | 226 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 227 | i2c_dev->client = client; |
| 228 | i2c_dev->state = PROBED; |
Benson Leung | 8e1ad4c | 2013-02-21 12:14:59 -0800 | [diff] [blame] | 229 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 230 | return 0; |
Benson Leung | 8016bcb | 2013-02-01 14:34:46 -0800 | [diff] [blame] | 231 | } |
| 232 | |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 233 | static int __init chromeos_laptop_dmi_matched(const struct dmi_system_id *id) |
| 234 | { |
| 235 | cros_laptop = (void *)id->driver_data; |
Dmitry Torokhov | 4f27f67 | 2018-03-20 15:31:30 -0700 | [diff] [blame] | 236 | pr_debug("DMI Matched %s\n", id->ident); |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 237 | |
| 238 | /* Indicate to dmi_scan that processing is done. */ |
| 239 | return 1; |
| 240 | } |
| 241 | |
| 242 | static int chromeos_laptop_probe(struct platform_device *pdev) |
Benson Leung | aabf3f4 | 2013-02-01 14:34:45 -0800 | [diff] [blame] | 243 | { |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 244 | struct i2c_peripheral *i2c_dev; |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 245 | int i; |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 246 | int ret = 0; |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 247 | |
| 248 | for (i = 0; i < MAX_I2C_PERIPHERALS; i++) { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 249 | i2c_dev = &cros_laptop->i2c_peripherals[i]; |
| 250 | |
| 251 | /* No more peripherals. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 252 | if (!i2c_dev->board_info.addr) |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 253 | break; |
| 254 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 255 | if (i2c_dev->state != UNPROBED) |
Benson Leung | 5502486 | 2014-07-15 17:43:11 -0700 | [diff] [blame] | 256 | continue; |
| 257 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 258 | if (chromeos_laptop_add_peripheral(i2c_dev) == -EPROBE_DEFER) |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 259 | ret = -EPROBE_DEFER; |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 262 | return ret; |
Benson Leung | aabf3f4 | 2013-02-01 14:34:45 -0800 | [diff] [blame] | 263 | } |
| 264 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 265 | static struct chromeos_laptop samsung_series_5_550 = { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 266 | .i2c_peripherals = { |
| 267 | /* Touchpad. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 268 | { |
| 269 | .board_info = { |
| 270 | I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR), |
| 271 | .flags = I2C_CLIENT_WAKE, |
| 272 | }, |
| 273 | .dmi_name = "trackpad", |
| 274 | .type = I2C_ADAPTER_SMBUS, |
| 275 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 276 | /* Light Sensor. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 277 | { |
| 278 | .board_info = { |
| 279 | I2C_BOARD_INFO("isl29018", ISL_ALS_I2C_ADDR), |
| 280 | }, |
| 281 | .dmi_name = "lightsensor", |
| 282 | .type = I2C_ADAPTER_SMBUS, |
| 283 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 284 | }, |
| 285 | }; |
| 286 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 287 | static struct chromeos_laptop samsung_series_5 = { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 288 | .i2c_peripherals = { |
| 289 | /* Light Sensor. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 290 | { |
| 291 | .board_info = { |
| 292 | I2C_BOARD_INFO("tsl2583", TAOS_ALS_I2C_ADDR), |
| 293 | }, |
| 294 | .type = I2C_ADAPTER_SMBUS, |
| 295 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 296 | }, |
| 297 | }; |
| 298 | |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 299 | static struct mxt_platform_data atmel_1664s_platform_data = { |
| 300 | .irqflags = IRQF_TRIGGER_FALLING, |
| 301 | }; |
| 302 | |
| 303 | static int chromebook_pixel_tp_keys[] = { |
| 304 | KEY_RESERVED, |
| 305 | KEY_RESERVED, |
| 306 | KEY_RESERVED, |
| 307 | KEY_RESERVED, |
| 308 | KEY_RESERVED, |
| 309 | BTN_LEFT |
| 310 | }; |
| 311 | |
| 312 | static struct mxt_platform_data chromebook_pixel_tp_platform_data = { |
| 313 | .irqflags = IRQF_TRIGGER_FALLING, |
| 314 | .t19_num_keys = ARRAY_SIZE(chromebook_pixel_tp_keys), |
| 315 | .t19_keymap = chromebook_pixel_tp_keys, |
| 316 | }; |
| 317 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 318 | static struct chromeos_laptop chromebook_pixel = { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 319 | .i2c_peripherals = { |
| 320 | /* Touch Screen. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 321 | { |
| 322 | .board_info = { |
| 323 | I2C_BOARD_INFO("atmel_mxt_ts", |
| 324 | ATMEL_TS_I2C_ADDR), |
| 325 | .platform_data = &atmel_1664s_platform_data, |
| 326 | .flags = I2C_CLIENT_WAKE, |
| 327 | }, |
| 328 | .dmi_name = "touchscreen", |
| 329 | .type = I2C_ADAPTER_PANEL, |
| 330 | .alt_addr = ATMEL_TS_I2C_BL_ADDR, |
| 331 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 332 | /* Touchpad. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 333 | { |
| 334 | .board_info = { |
| 335 | I2C_BOARD_INFO("atmel_mxt_tp", |
| 336 | ATMEL_TP_I2C_ADDR), |
| 337 | .platform_data = |
| 338 | &chromebook_pixel_tp_platform_data, |
| 339 | .flags = I2C_CLIENT_WAKE, |
| 340 | }, |
| 341 | .dmi_name = "trackpad", |
| 342 | .type = I2C_ADAPTER_VGADDC, |
| 343 | .alt_addr = ATMEL_TP_I2C_BL_ADDR, |
| 344 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 345 | /* Light Sensor. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 346 | { |
| 347 | .board_info = { |
| 348 | I2C_BOARD_INFO("isl29018", ISL_ALS_I2C_ADDR), |
| 349 | }, |
| 350 | .dmi_name = "lightsensor", |
| 351 | .type = I2C_ADAPTER_PANEL, |
| 352 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 353 | }, |
| 354 | }; |
| 355 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 356 | static struct chromeos_laptop hp_chromebook_14 = { |
Benson Leung | 5ea9567 | 2014-06-17 14:02:01 -0700 | [diff] [blame] | 357 | .i2c_peripherals = { |
| 358 | /* Touchpad. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 359 | { |
| 360 | .board_info = { |
| 361 | I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR), |
| 362 | .flags = I2C_CLIENT_WAKE, |
| 363 | }, |
| 364 | .dmi_name = "trackpad", |
| 365 | .type = I2C_ADAPTER_DESIGNWARE_0, |
| 366 | }, |
Benson Leung | 5ea9567 | 2014-06-17 14:02:01 -0700 | [diff] [blame] | 367 | }, |
| 368 | }; |
| 369 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 370 | static struct chromeos_laptop dell_chromebook_11 = { |
Mohammed Habibulla | 0e1e5e5 | 2014-06-17 14:02:02 -0700 | [diff] [blame] | 371 | .i2c_peripherals = { |
| 372 | /* Touchpad. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 373 | { |
| 374 | .board_info = { |
| 375 | I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR), |
| 376 | .flags = I2C_CLIENT_WAKE, |
| 377 | }, |
| 378 | .dmi_name = "trackpad", |
| 379 | .type = I2C_ADAPTER_DESIGNWARE_0, |
| 380 | }, |
Charlie Mooney | 9e96aa7 | 2016-05-02 08:57:17 +0800 | [diff] [blame] | 381 | /* Elan Touchpad option. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 382 | { |
| 383 | .board_info = { |
| 384 | I2C_BOARD_INFO("elan_i2c", ELAN_TP_I2C_ADDR), |
| 385 | .flags = I2C_CLIENT_WAKE, |
| 386 | }, |
| 387 | .dmi_name = "trackpad", |
| 388 | .type = I2C_ADAPTER_DESIGNWARE_0, |
| 389 | }, |
Mohammed Habibulla | 0e1e5e5 | 2014-06-17 14:02:02 -0700 | [diff] [blame] | 390 | }, |
| 391 | }; |
| 392 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 393 | static struct chromeos_laptop toshiba_cb35 = { |
Gene Chen | 963cb6f | 2014-06-17 14:02:03 -0700 | [diff] [blame] | 394 | .i2c_peripherals = { |
| 395 | /* Touchpad. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 396 | { |
| 397 | .board_info = { |
| 398 | I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR), |
| 399 | .flags = I2C_CLIENT_WAKE, |
| 400 | }, |
| 401 | .dmi_name = "trackpad", |
| 402 | .type = I2C_ADAPTER_DESIGNWARE_0, |
| 403 | }, |
Gene Chen | 963cb6f | 2014-06-17 14:02:03 -0700 | [diff] [blame] | 404 | }, |
| 405 | }; |
| 406 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 407 | static struct chromeos_laptop acer_c7_chromebook = { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 408 | .i2c_peripherals = { |
| 409 | /* Touchpad. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 410 | { |
| 411 | .board_info = { |
| 412 | I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR), |
| 413 | .flags = I2C_CLIENT_WAKE, |
| 414 | }, |
| 415 | .dmi_name = "trackpad", |
| 416 | .type = I2C_ADAPTER_SMBUS, |
| 417 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 418 | }, |
| 419 | }; |
| 420 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 421 | static struct chromeos_laptop acer_ac700 = { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 422 | .i2c_peripherals = { |
| 423 | /* Light Sensor. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 424 | { |
| 425 | .board_info = { |
| 426 | I2C_BOARD_INFO("tsl2583", TAOS_ALS_I2C_ADDR), |
| 427 | }, |
| 428 | .type = I2C_ADAPTER_SMBUS, |
| 429 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 430 | }, |
| 431 | }; |
| 432 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 433 | static struct chromeos_laptop acer_c720 = { |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 434 | .i2c_peripherals = { |
Michael Mullin | b90b3c4 | 2014-07-15 20:00:54 -0400 | [diff] [blame] | 435 | /* Touchscreen. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 436 | { |
| 437 | .board_info = { |
| 438 | I2C_BOARD_INFO("atmel_mxt_ts", |
| 439 | ATMEL_TS_I2C_ADDR), |
| 440 | .platform_data = &atmel_1664s_platform_data, |
| 441 | .flags = I2C_CLIENT_WAKE, |
| 442 | }, |
| 443 | .dmi_name = "touchscreen", |
| 444 | .type = I2C_ADAPTER_DESIGNWARE_1, |
| 445 | .alt_addr = ATMEL_TS_I2C_BL_ADDR, |
| 446 | }, |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 447 | /* Touchpad. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 448 | { |
| 449 | .board_info = { |
| 450 | I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR), |
| 451 | .flags = I2C_CLIENT_WAKE, |
| 452 | }, |
| 453 | .dmi_name = "trackpad", |
| 454 | .type = I2C_ADAPTER_DESIGNWARE_0, |
| 455 | }, |
Benson Leung | 9bd9a90 | 2016-05-02 08:57:16 +0800 | [diff] [blame] | 456 | /* Elan Touchpad option. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 457 | { |
| 458 | .board_info = { |
| 459 | I2C_BOARD_INFO("elan_i2c", ELAN_TP_I2C_ADDR), |
| 460 | .flags = I2C_CLIENT_WAKE, |
| 461 | }, |
| 462 | .dmi_name = "trackpad", |
| 463 | .type = I2C_ADAPTER_DESIGNWARE_0, |
| 464 | }, |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 465 | /* Light Sensor. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 466 | { |
| 467 | .board_info = { |
| 468 | I2C_BOARD_INFO("isl29018", ISL_ALS_I2C_ADDR), |
| 469 | }, |
| 470 | .dmi_name = "lightsensor", |
| 471 | .type = I2C_ADAPTER_DESIGNWARE_1, |
| 472 | }, |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 473 | }, |
| 474 | }; |
| 475 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 476 | static struct chromeos_laptop hp_pavilion_14_chromebook = { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 477 | .i2c_peripherals = { |
| 478 | /* Touchpad. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 479 | { |
| 480 | .board_info = { |
| 481 | I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR), |
| 482 | .flags = I2C_CLIENT_WAKE, |
| 483 | }, |
| 484 | .dmi_name = "trackpad", |
| 485 | .type = I2C_ADAPTER_SMBUS, |
| 486 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 487 | }, |
| 488 | }; |
| 489 | |
Dmitry Torokhov | fc88bbd | 2018-03-06 10:59:15 -0800 | [diff] [blame] | 490 | static struct chromeos_laptop cr48 = { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 491 | .i2c_peripherals = { |
| 492 | /* Light Sensor. */ |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 493 | { |
| 494 | .board_info = { |
| 495 | I2C_BOARD_INFO("tsl2563", TAOS_ALS_I2C_ADDR), |
| 496 | }, |
| 497 | .type = I2C_ADAPTER_SMBUS, |
| 498 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 499 | }, |
| 500 | }; |
| 501 | |
| 502 | #define _CBDD(board_) \ |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 503 | .callback = chromeos_laptop_dmi_matched, \ |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 504 | .driver_data = (void *)&board_ |
| 505 | |
Christoph Hellwig | 6faadbb | 2017-09-14 11:59:30 +0200 | [diff] [blame] | 506 | static const struct dmi_system_id chromeos_laptop_dmi_table[] __initconst = { |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 507 | { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 508 | .ident = "Samsung Series 5 550", |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 509 | .matches = { |
| 510 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"), |
| 511 | DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"), |
| 512 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 513 | _CBDD(samsung_series_5_550), |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 514 | }, |
| 515 | { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 516 | .ident = "Samsung Series 5", |
Benson Leung | 8016bcb | 2013-02-01 14:34:46 -0800 | [diff] [blame] | 517 | .matches = { |
| 518 | DMI_MATCH(DMI_PRODUCT_NAME, "Alex"), |
| 519 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 520 | _CBDD(samsung_series_5), |
Benson Leung | 8016bcb | 2013-02-01 14:34:46 -0800 | [diff] [blame] | 521 | }, |
| 522 | { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 523 | .ident = "Chromebook Pixel", |
Benson Leung | aabf3f4 | 2013-02-01 14:34:45 -0800 | [diff] [blame] | 524 | .matches = { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 525 | DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), |
| 526 | DMI_MATCH(DMI_PRODUCT_NAME, "Link"), |
Benson Leung | aabf3f4 | 2013-02-01 14:34:45 -0800 | [diff] [blame] | 527 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 528 | _CBDD(chromebook_pixel), |
Benson Leung | aabf3f4 | 2013-02-01 14:34:45 -0800 | [diff] [blame] | 529 | }, |
| 530 | { |
Mohammed Habibulla | 0e1e5e5 | 2014-06-17 14:02:02 -0700 | [diff] [blame] | 531 | .ident = "Wolf", |
| 532 | .matches = { |
| 533 | DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"), |
| 534 | DMI_MATCH(DMI_PRODUCT_NAME, "Wolf"), |
| 535 | }, |
| 536 | _CBDD(dell_chromebook_11), |
| 537 | }, |
| 538 | { |
Benson Leung | 5ea9567 | 2014-06-17 14:02:01 -0700 | [diff] [blame] | 539 | .ident = "HP Chromebook 14", |
| 540 | .matches = { |
| 541 | DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"), |
| 542 | DMI_MATCH(DMI_PRODUCT_NAME, "Falco"), |
| 543 | }, |
| 544 | _CBDD(hp_chromebook_14), |
| 545 | }, |
| 546 | { |
Gene Chen | 963cb6f | 2014-06-17 14:02:03 -0700 | [diff] [blame] | 547 | .ident = "Toshiba CB35", |
| 548 | .matches = { |
| 549 | DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"), |
| 550 | DMI_MATCH(DMI_PRODUCT_NAME, "Leon"), |
| 551 | }, |
| 552 | _CBDD(toshiba_cb35), |
| 553 | }, |
| 554 | { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 555 | .ident = "Acer C7 Chromebook", |
| 556 | .matches = { |
| 557 | DMI_MATCH(DMI_PRODUCT_NAME, "Parrot"), |
| 558 | }, |
| 559 | _CBDD(acer_c7_chromebook), |
| 560 | }, |
| 561 | { |
| 562 | .ident = "Acer AC700", |
Benson Leung | aabf3f4 | 2013-02-01 14:34:45 -0800 | [diff] [blame] | 563 | .matches = { |
| 564 | DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"), |
| 565 | }, |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 566 | _CBDD(acer_ac700), |
| 567 | }, |
| 568 | { |
Mika Westerberg | da3b0ab | 2014-06-17 14:02:00 -0700 | [diff] [blame] | 569 | .ident = "Acer C720", |
| 570 | .matches = { |
| 571 | DMI_MATCH(DMI_PRODUCT_NAME, "Peppy"), |
| 572 | }, |
| 573 | _CBDD(acer_c720), |
| 574 | }, |
| 575 | { |
Aaron Durbin | ec199dd | 2013-10-20 20:58:24 -0700 | [diff] [blame] | 576 | .ident = "HP Pavilion 14 Chromebook", |
| 577 | .matches = { |
| 578 | DMI_MATCH(DMI_PRODUCT_NAME, "Butterfly"), |
| 579 | }, |
| 580 | _CBDD(hp_pavilion_14_chromebook), |
| 581 | }, |
| 582 | { |
| 583 | .ident = "Cr-48", |
| 584 | .matches = { |
| 585 | DMI_MATCH(DMI_PRODUCT_NAME, "Mario"), |
| 586 | }, |
| 587 | _CBDD(cr48), |
Benson Leung | aabf3f4 | 2013-02-01 14:34:45 -0800 | [diff] [blame] | 588 | }, |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 589 | { } |
| 590 | }; |
| 591 | MODULE_DEVICE_TABLE(dmi, chromeos_laptop_dmi_table); |
| 592 | |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 593 | static struct platform_device *cros_platform_device; |
| 594 | |
| 595 | static struct platform_driver cros_platform_driver = { |
| 596 | .driver = { |
| 597 | .name = "chromeos_laptop", |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 598 | }, |
| 599 | .probe = chromeos_laptop_probe, |
| 600 | }; |
| 601 | |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 602 | static int __init chromeos_laptop_init(void) |
| 603 | { |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 604 | int ret; |
Robin Schroer | 49c68a2 | 2014-05-29 20:45:07 +0200 | [diff] [blame] | 605 | |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 606 | if (!dmi_check_system(chromeos_laptop_dmi_table)) { |
Dmitry Torokhov | 4f27f67 | 2018-03-20 15:31:30 -0700 | [diff] [blame] | 607 | pr_debug("unsupported system\n"); |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 608 | return -ENODEV; |
| 609 | } |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 610 | |
| 611 | ret = platform_driver_register(&cros_platform_driver); |
| 612 | if (ret) |
| 613 | return ret; |
| 614 | |
| 615 | cros_platform_device = platform_device_alloc("chromeos_laptop", -1); |
| 616 | if (!cros_platform_device) { |
| 617 | ret = -ENOMEM; |
| 618 | goto fail_platform_device1; |
| 619 | } |
| 620 | |
| 621 | ret = platform_device_add(cros_platform_device); |
| 622 | if (ret) |
| 623 | goto fail_platform_device2; |
| 624 | |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 625 | return 0; |
Benson Leung | 9ad3692 | 2013-10-20 20:58:25 -0700 | [diff] [blame] | 626 | |
| 627 | fail_platform_device2: |
| 628 | platform_device_put(cros_platform_device); |
| 629 | fail_platform_device1: |
| 630 | platform_driver_unregister(&cros_platform_driver); |
| 631 | return ret; |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | static void __exit chromeos_laptop_exit(void) |
| 635 | { |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 636 | struct i2c_peripheral *i2c_dev; |
| 637 | int i; |
Wei Yongjun | 2b8454a | 2013-11-27 11:34:58 +0800 | [diff] [blame] | 638 | |
| 639 | platform_device_unregister(cros_platform_device); |
| 640 | platform_driver_unregister(&cros_platform_driver); |
Dmitry Torokhov | 28cd38f | 2018-03-20 15:31:32 -0700 | [diff] [blame^] | 641 | |
| 642 | for (i = 0; i < MAX_I2C_PERIPHERALS; i++) { |
| 643 | i2c_dev = &cros_laptop->i2c_peripherals[i]; |
| 644 | |
| 645 | /* No more peripherals */ |
| 646 | if (!i2c_dev->board_info.type) |
| 647 | break; |
| 648 | |
| 649 | if (i2c_dev->state == PROBED) |
| 650 | i2c_unregister_device(i2c_dev->client); |
| 651 | } |
Benson Leung | d1381f4 | 2012-10-25 14:21:21 -0700 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | module_init(chromeos_laptop_init); |
| 655 | module_exit(chromeos_laptop_exit); |
| 656 | |
| 657 | MODULE_DESCRIPTION("Chrome OS Laptop driver"); |
| 658 | MODULE_AUTHOR("Benson Leung <bleung@chromium.org>"); |
| 659 | MODULE_LICENSE("GPL"); |