Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 Andrew Duggan <aduggan@synaptics.com> |
| 3 | * Copyright (c) 2013 Synaptics Incorporated |
| 4 | * Copyright (c) 2014 Benjamin Tissoires <benjamin.tissoires@gmail.com> |
| 5 | * Copyright (c) 2014 Red Hat, Inc |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the Free |
| 9 | * Software Foundation; either version 2 of the License, or (at your option) |
| 10 | * any later version. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/hid.h> |
| 15 | #include <linux/input.h> |
| 16 | #include <linux/input/mt.h> |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 17 | #include <linux/irq.h> |
| 18 | #include <linux/irqdomain.h> |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 19 | #include <linux/module.h> |
| 20 | #include <linux/pm.h> |
| 21 | #include <linux/slab.h> |
| 22 | #include <linux/wait.h> |
| 23 | #include <linux/sched.h> |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 24 | #include <linux/rmi.h> |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 25 | #include "hid-ids.h" |
| 26 | |
| 27 | #define RMI_MOUSE_REPORT_ID 0x01 /* Mouse emulation Report */ |
| 28 | #define RMI_WRITE_REPORT_ID 0x09 /* Output Report */ |
| 29 | #define RMI_READ_ADDR_REPORT_ID 0x0a /* Output Report */ |
| 30 | #define RMI_READ_DATA_REPORT_ID 0x0b /* Input Report */ |
| 31 | #define RMI_ATTN_REPORT_ID 0x0c /* Input Report */ |
| 32 | #define RMI_SET_RMI_MODE_REPORT_ID 0x0f /* Feature Report */ |
| 33 | |
| 34 | /* flags */ |
Dan Carpenter | af43c40 | 2015-05-14 11:32:56 +0300 | [diff] [blame] | 35 | #define RMI_READ_REQUEST_PENDING 0 |
| 36 | #define RMI_READ_DATA_PENDING 1 |
| 37 | #define RMI_STARTED 2 |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 38 | |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 39 | /* device flags */ |
| 40 | #define RMI_DEVICE BIT(0) |
Andrew Duggan | 79364d8 | 2015-01-08 14:51:34 -0800 | [diff] [blame] | 41 | #define RMI_DEVICE_HAS_PHYS_BUTTONS BIT(1) |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 42 | |
Andrew Duggan | 7035f3a | 2015-07-10 12:48:21 -0700 | [diff] [blame] | 43 | /* |
| 44 | * retrieve the ctrl registers |
| 45 | * the ctrl register has a size of 20 but a fw bug split it into 16 + 4, |
| 46 | * and there is no way to know if the first 20 bytes are here or not. |
| 47 | * We use only the first 12 bytes, so get only them. |
| 48 | */ |
| 49 | #define RMI_F11_CTRL_REG_COUNT 12 |
| 50 | |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 51 | enum rmi_mode_type { |
| 52 | RMI_MODE_OFF = 0, |
| 53 | RMI_MODE_ATTN_REPORTS = 1, |
| 54 | RMI_MODE_NO_PACKED_ATTN_REPORTS = 2, |
| 55 | }; |
| 56 | |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 57 | /** |
| 58 | * struct rmi_data - stores information for hid communication |
| 59 | * |
| 60 | * @page_mutex: Locks current page to avoid changing pages in unexpected ways. |
| 61 | * @page: Keeps track of the current virtual page |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 62 | * @xport: transport device to be registered with the RMI4 core. |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 63 | * |
| 64 | * @wait: Used for waiting for read data |
| 65 | * |
| 66 | * @writeReport: output buffer when writing RMI registers |
| 67 | * @readReport: input buffer when reading RMI registers |
| 68 | * |
| 69 | * @input_report_size: size of an input report (advertised by HID) |
| 70 | * @output_report_size: size of an output report (advertised by HID) |
| 71 | * |
| 72 | * @flags: flags for the current device (started, reading, etc...) |
| 73 | * |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 74 | * @reset_work: worker which will be called in case of a mouse report |
| 75 | * @hdev: pointer to the struct hid_device |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 76 | * |
| 77 | * @device_flags: flags which describe the device |
| 78 | * |
| 79 | * @domain: the IRQ domain allocated for this RMI4 device |
| 80 | * @rmi_irq: the irq that will be used to generate events to rmi-core |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 81 | */ |
| 82 | struct rmi_data { |
| 83 | struct mutex page_mutex; |
| 84 | int page; |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 85 | struct rmi_transport_dev xport; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 86 | |
| 87 | wait_queue_head_t wait; |
| 88 | |
| 89 | u8 *writeReport; |
| 90 | u8 *readReport; |
| 91 | |
Aaron Ma | 3064a03 | 2018-02-03 23:57:15 +0800 | [diff] [blame^] | 92 | u32 input_report_size; |
| 93 | u32 output_report_size; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 94 | |
| 95 | unsigned long flags; |
| 96 | |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 97 | struct work_struct reset_work; |
| 98 | struct hid_device *hdev; |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 99 | |
| 100 | unsigned long device_flags; |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 101 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 102 | struct irq_domain *domain; |
| 103 | int rmi_irq; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | #define RMI_PAGE(addr) (((addr) >> 8) & 0xff) |
| 107 | |
| 108 | static int rmi_write_report(struct hid_device *hdev, u8 *report, int len); |
| 109 | |
| 110 | /** |
| 111 | * rmi_set_page - Set RMI page |
| 112 | * @hdev: The pointer to the hid_device struct |
| 113 | * @page: The new page address. |
| 114 | * |
| 115 | * RMI devices have 16-bit addressing, but some of the physical |
| 116 | * implementations (like SMBus) only have 8-bit addressing. So RMI implements |
| 117 | * a page address at 0xff of every page so we can reliable page addresses |
| 118 | * every 256 registers. |
| 119 | * |
| 120 | * The page_mutex lock must be held when this function is entered. |
| 121 | * |
| 122 | * Returns zero on success, non-zero on failure. |
| 123 | */ |
| 124 | static int rmi_set_page(struct hid_device *hdev, u8 page) |
| 125 | { |
| 126 | struct rmi_data *data = hid_get_drvdata(hdev); |
| 127 | int retval; |
| 128 | |
| 129 | data->writeReport[0] = RMI_WRITE_REPORT_ID; |
| 130 | data->writeReport[1] = 1; |
| 131 | data->writeReport[2] = 0xFF; |
| 132 | data->writeReport[4] = page; |
| 133 | |
| 134 | retval = rmi_write_report(hdev, data->writeReport, |
| 135 | data->output_report_size); |
| 136 | if (retval != data->output_report_size) { |
| 137 | dev_err(&hdev->dev, |
| 138 | "%s: set page failed: %d.", __func__, retval); |
| 139 | return retval; |
| 140 | } |
| 141 | |
| 142 | data->page = page; |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | static int rmi_set_mode(struct hid_device *hdev, u8 mode) |
| 147 | { |
| 148 | int ret; |
Benjamin Tissoires | 6dab07d | 2016-11-21 11:48:42 +0100 | [diff] [blame] | 149 | const u8 txbuf[2] = {RMI_SET_RMI_MODE_REPORT_ID, mode}; |
| 150 | u8 *buf; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 151 | |
Benjamin Tissoires | 6dab07d | 2016-11-21 11:48:42 +0100 | [diff] [blame] | 152 | buf = kmemdup(txbuf, sizeof(txbuf), GFP_KERNEL); |
| 153 | if (!buf) |
| 154 | return -ENOMEM; |
| 155 | |
| 156 | ret = hid_hw_raw_request(hdev, RMI_SET_RMI_MODE_REPORT_ID, buf, |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 157 | sizeof(txbuf), HID_FEATURE_REPORT, HID_REQ_SET_REPORT); |
Benjamin Tissoires | 6dab07d | 2016-11-21 11:48:42 +0100 | [diff] [blame] | 158 | kfree(buf); |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 159 | if (ret < 0) { |
| 160 | dev_err(&hdev->dev, "unable to set rmi mode to %d (%d)\n", mode, |
| 161 | ret); |
| 162 | return ret; |
| 163 | } |
| 164 | |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | static int rmi_write_report(struct hid_device *hdev, u8 *report, int len) |
| 169 | { |
| 170 | int ret; |
| 171 | |
| 172 | ret = hid_hw_output_report(hdev, (void *)report, len); |
| 173 | if (ret < 0) { |
| 174 | dev_err(&hdev->dev, "failed to write hid report (%d)\n", ret); |
| 175 | return ret; |
| 176 | } |
| 177 | |
| 178 | return ret; |
| 179 | } |
| 180 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 181 | static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr, |
| 182 | void *buf, size_t len) |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 183 | { |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 184 | struct rmi_data *data = container_of(xport, struct rmi_data, xport); |
| 185 | struct hid_device *hdev = data->hdev; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 186 | int ret; |
| 187 | int bytes_read; |
| 188 | int bytes_needed; |
| 189 | int retries; |
| 190 | int read_input_count; |
| 191 | |
| 192 | mutex_lock(&data->page_mutex); |
| 193 | |
| 194 | if (RMI_PAGE(addr) != data->page) { |
| 195 | ret = rmi_set_page(hdev, RMI_PAGE(addr)); |
| 196 | if (ret < 0) |
| 197 | goto exit; |
| 198 | } |
| 199 | |
| 200 | for (retries = 5; retries > 0; retries--) { |
| 201 | data->writeReport[0] = RMI_READ_ADDR_REPORT_ID; |
| 202 | data->writeReport[1] = 0; /* old 1 byte read count */ |
| 203 | data->writeReport[2] = addr & 0xFF; |
| 204 | data->writeReport[3] = (addr >> 8) & 0xFF; |
| 205 | data->writeReport[4] = len & 0xFF; |
| 206 | data->writeReport[5] = (len >> 8) & 0xFF; |
| 207 | |
| 208 | set_bit(RMI_READ_REQUEST_PENDING, &data->flags); |
| 209 | |
| 210 | ret = rmi_write_report(hdev, data->writeReport, |
| 211 | data->output_report_size); |
| 212 | if (ret != data->output_report_size) { |
| 213 | clear_bit(RMI_READ_REQUEST_PENDING, &data->flags); |
| 214 | dev_err(&hdev->dev, |
| 215 | "failed to write request output report (%d)\n", |
| 216 | ret); |
| 217 | goto exit; |
| 218 | } |
| 219 | |
| 220 | bytes_read = 0; |
| 221 | bytes_needed = len; |
| 222 | while (bytes_read < len) { |
| 223 | if (!wait_event_timeout(data->wait, |
| 224 | test_bit(RMI_READ_DATA_PENDING, &data->flags), |
| 225 | msecs_to_jiffies(1000))) { |
| 226 | hid_warn(hdev, "%s: timeout elapsed\n", |
| 227 | __func__); |
| 228 | ret = -EAGAIN; |
| 229 | break; |
| 230 | } |
| 231 | |
| 232 | read_input_count = data->readReport[1]; |
| 233 | memcpy(buf + bytes_read, &data->readReport[2], |
| 234 | read_input_count < bytes_needed ? |
| 235 | read_input_count : bytes_needed); |
| 236 | |
| 237 | bytes_read += read_input_count; |
| 238 | bytes_needed -= read_input_count; |
| 239 | clear_bit(RMI_READ_DATA_PENDING, &data->flags); |
| 240 | } |
| 241 | |
| 242 | if (ret >= 0) { |
| 243 | ret = 0; |
| 244 | break; |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | exit: |
| 249 | clear_bit(RMI_READ_REQUEST_PENDING, &data->flags); |
| 250 | mutex_unlock(&data->page_mutex); |
| 251 | return ret; |
| 252 | } |
| 253 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 254 | static int rmi_hid_write_block(struct rmi_transport_dev *xport, u16 addr, |
| 255 | const void *buf, size_t len) |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 256 | { |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 257 | struct rmi_data *data = container_of(xport, struct rmi_data, xport); |
| 258 | struct hid_device *hdev = data->hdev; |
Andrew Duggan | dd8df28 | 2015-02-24 17:36:48 -0800 | [diff] [blame] | 259 | int ret; |
| 260 | |
| 261 | mutex_lock(&data->page_mutex); |
| 262 | |
| 263 | if (RMI_PAGE(addr) != data->page) { |
| 264 | ret = rmi_set_page(hdev, RMI_PAGE(addr)); |
| 265 | if (ret < 0) |
| 266 | goto exit; |
| 267 | } |
| 268 | |
| 269 | data->writeReport[0] = RMI_WRITE_REPORT_ID; |
| 270 | data->writeReport[1] = len; |
| 271 | data->writeReport[2] = addr & 0xFF; |
| 272 | data->writeReport[3] = (addr >> 8) & 0xFF; |
| 273 | memcpy(&data->writeReport[4], buf, len); |
| 274 | |
| 275 | ret = rmi_write_report(hdev, data->writeReport, |
| 276 | data->output_report_size); |
| 277 | if (ret < 0) { |
| 278 | dev_err(&hdev->dev, |
| 279 | "failed to write request output report (%d)\n", |
| 280 | ret); |
| 281 | goto exit; |
| 282 | } |
| 283 | ret = 0; |
| 284 | |
| 285 | exit: |
| 286 | mutex_unlock(&data->page_mutex); |
| 287 | return ret; |
| 288 | } |
| 289 | |
Andrew Duggan | 9a98b33 | 2015-07-16 17:14:00 -0700 | [diff] [blame] | 290 | static int rmi_reset_attn_mode(struct hid_device *hdev) |
| 291 | { |
| 292 | struct rmi_data *data = hid_get_drvdata(hdev); |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 293 | struct rmi_device *rmi_dev = data->xport.rmi_dev; |
Andrew Duggan | 9a98b33 | 2015-07-16 17:14:00 -0700 | [diff] [blame] | 294 | int ret; |
| 295 | |
| 296 | ret = rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); |
| 297 | if (ret) |
| 298 | return ret; |
| 299 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 300 | if (test_bit(RMI_STARTED, &data->flags)) |
| 301 | ret = rmi_dev->driver->reset_handler(rmi_dev); |
Andrew Duggan | 9a98b33 | 2015-07-16 17:14:00 -0700 | [diff] [blame] | 302 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 303 | return ret; |
Andrew Duggan | 9a98b33 | 2015-07-16 17:14:00 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 306 | static void rmi_reset_work(struct work_struct *work) |
| 307 | { |
| 308 | struct rmi_data *hdata = container_of(work, struct rmi_data, |
| 309 | reset_work); |
| 310 | |
| 311 | /* switch the device to RMI if we receive a generic mouse report */ |
Andrew Duggan | 9a98b33 | 2015-07-16 17:14:00 -0700 | [diff] [blame] | 312 | rmi_reset_attn_mode(hdata->hdev); |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 313 | } |
| 314 | |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 315 | static int rmi_input_event(struct hid_device *hdev, u8 *data, int size) |
| 316 | { |
| 317 | struct rmi_data *hdata = hid_get_drvdata(hdev); |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 318 | struct rmi_device *rmi_dev = hdata->xport.rmi_dev; |
| 319 | unsigned long flags; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 320 | |
| 321 | if (!(test_bit(RMI_STARTED, &hdata->flags))) |
| 322 | return 0; |
| 323 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 324 | local_irq_save(flags); |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 325 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 326 | rmi_set_attn_data(rmi_dev, data[1], &data[2], size - 2); |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 327 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 328 | generic_handle_irq(hdata->rmi_irq); |
| 329 | |
| 330 | local_irq_restore(flags); |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 331 | |
| 332 | return 1; |
| 333 | } |
| 334 | |
| 335 | static int rmi_read_data_event(struct hid_device *hdev, u8 *data, int size) |
| 336 | { |
| 337 | struct rmi_data *hdata = hid_get_drvdata(hdev); |
| 338 | |
| 339 | if (!test_bit(RMI_READ_REQUEST_PENDING, &hdata->flags)) { |
Andrew Duggan | 01a5f8a | 2014-07-11 14:35:51 -0700 | [diff] [blame] | 340 | hid_dbg(hdev, "no read request pending\n"); |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | memcpy(hdata->readReport, data, size < hdata->input_report_size ? |
| 345 | size : hdata->input_report_size); |
| 346 | set_bit(RMI_READ_DATA_PENDING, &hdata->flags); |
| 347 | wake_up(&hdata->wait); |
| 348 | |
| 349 | return 1; |
| 350 | } |
| 351 | |
Benjamin Tissoires | 5b65c2a | 2014-09-10 18:02:37 -0700 | [diff] [blame] | 352 | static int rmi_check_sanity(struct hid_device *hdev, u8 *data, int size) |
| 353 | { |
| 354 | int valid_size = size; |
| 355 | /* |
| 356 | * On the Dell XPS 13 9333, the bus sometimes get confused and fills |
| 357 | * the report with a sentinel value "ff". Synaptics told us that such |
| 358 | * behavior does not comes from the touchpad itself, so we filter out |
| 359 | * such reports here. |
| 360 | */ |
| 361 | |
| 362 | while ((data[valid_size - 1] == 0xff) && valid_size > 0) |
| 363 | valid_size--; |
| 364 | |
| 365 | return valid_size; |
| 366 | } |
| 367 | |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 368 | static int rmi_raw_event(struct hid_device *hdev, |
| 369 | struct hid_report *report, u8 *data, int size) |
| 370 | { |
Andrew Duggan | ef14a4bf | 2017-10-17 18:37:36 -0700 | [diff] [blame] | 371 | struct rmi_data *hdata = hid_get_drvdata(hdev); |
| 372 | |
| 373 | if (!(hdata->device_flags & RMI_DEVICE)) |
| 374 | return 0; |
| 375 | |
Benjamin Tissoires | 5b65c2a | 2014-09-10 18:02:37 -0700 | [diff] [blame] | 376 | size = rmi_check_sanity(hdev, data, size); |
| 377 | if (size < 2) |
| 378 | return 0; |
| 379 | |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 380 | switch (data[0]) { |
| 381 | case RMI_READ_DATA_REPORT_ID: |
| 382 | return rmi_read_data_event(hdev, data, size); |
| 383 | case RMI_ATTN_REPORT_ID: |
| 384 | return rmi_input_event(hdev, data, size); |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 385 | default: |
| 386 | return 1; |
| 387 | } |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | static int rmi_event(struct hid_device *hdev, struct hid_field *field, |
| 393 | struct hid_usage *usage, __s32 value) |
| 394 | { |
| 395 | struct rmi_data *data = hid_get_drvdata(hdev); |
| 396 | |
| 397 | if ((data->device_flags & RMI_DEVICE) && |
| 398 | (field->application == HID_GD_POINTER || |
| 399 | field->application == HID_GD_MOUSE)) { |
Andrew Duggan | 79364d8 | 2015-01-08 14:51:34 -0800 | [diff] [blame] | 400 | if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS) { |
| 401 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) |
| 402 | return 0; |
| 403 | |
| 404 | if ((usage->hid == HID_GD_X || usage->hid == HID_GD_Y) |
| 405 | && !value) |
| 406 | return 1; |
| 407 | } |
| 408 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 409 | schedule_work(&data->reset_work); |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 410 | return 1; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | return 0; |
| 414 | } |
| 415 | |
Geert Uytterhoeven | a278e26 | 2014-06-11 21:03:18 +0200 | [diff] [blame] | 416 | #ifdef CONFIG_PM |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 417 | static int rmi_suspend(struct hid_device *hdev, pm_message_t message) |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 418 | { |
| 419 | struct rmi_data *data = hid_get_drvdata(hdev); |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 420 | struct rmi_device *rmi_dev = data->xport.rmi_dev; |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 421 | int ret; |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 422 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 423 | if (!(data->device_flags & RMI_DEVICE)) |
| 424 | return 0; |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 425 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 426 | ret = rmi_driver_suspend(rmi_dev, false); |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 427 | if (ret) { |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 428 | hid_warn(hdev, "Failed to suspend device: %d\n", ret); |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 429 | return ret; |
| 430 | } |
| 431 | |
| 432 | return 0; |
| 433 | } |
| 434 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 435 | static int rmi_post_resume(struct hid_device *hdev) |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 436 | { |
Andrew Duggan | 7035f3a | 2015-07-10 12:48:21 -0700 | [diff] [blame] | 437 | struct rmi_data *data = hid_get_drvdata(hdev); |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 438 | struct rmi_device *rmi_dev = data->xport.rmi_dev; |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 439 | int ret; |
| 440 | |
Andrew Duggan | b786ae8 | 2016-01-26 15:40:36 -0800 | [diff] [blame] | 441 | if (!(data->device_flags & RMI_DEVICE)) |
| 442 | return 0; |
| 443 | |
Lyude | cac72b9 | 2017-07-22 21:15:09 -0400 | [diff] [blame] | 444 | /* Make sure the HID device is ready to receive events */ |
| 445 | ret = hid_hw_open(hdev); |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 446 | if (ret) |
| 447 | return ret; |
| 448 | |
Lyude | cac72b9 | 2017-07-22 21:15:09 -0400 | [diff] [blame] | 449 | ret = rmi_reset_attn_mode(hdev); |
| 450 | if (ret) |
| 451 | goto out; |
| 452 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 453 | ret = rmi_driver_resume(rmi_dev, false); |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 454 | if (ret) { |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 455 | hid_warn(hdev, "Failed to resume device: %d\n", ret); |
Lyude | cac72b9 | 2017-07-22 21:15:09 -0400 | [diff] [blame] | 456 | goto out; |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 457 | } |
| 458 | |
Lyude | cac72b9 | 2017-07-22 21:15:09 -0400 | [diff] [blame] | 459 | out: |
| 460 | hid_hw_close(hdev); |
| 461 | return ret; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 462 | } |
Geert Uytterhoeven | a278e26 | 2014-06-11 21:03:18 +0200 | [diff] [blame] | 463 | #endif /* CONFIG_PM */ |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 464 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 465 | static int rmi_hid_reset(struct rmi_transport_dev *xport, u16 reset_addr) |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 466 | { |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 467 | struct rmi_data *data = container_of(xport, struct rmi_data, xport); |
| 468 | struct hid_device *hdev = data->hdev; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 469 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 470 | return rmi_reset_attn_mode(hdev); |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 471 | } |
| 472 | |
Dmitry Torokhov | 9154301 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 473 | static int rmi_input_configured(struct hid_device *hdev, struct hid_input *hi) |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 474 | { |
| 475 | struct rmi_data *data = hid_get_drvdata(hdev); |
| 476 | struct input_dev *input = hi->input; |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 477 | int ret = 0; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 478 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 479 | if (!(data->device_flags & RMI_DEVICE)) |
| 480 | return 0; |
| 481 | |
| 482 | data->xport.input = input; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 483 | |
| 484 | hid_dbg(hdev, "Opening low level driver\n"); |
| 485 | ret = hid_hw_open(hdev); |
| 486 | if (ret) |
Dmitry Torokhov | 9154301 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 487 | return ret; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 488 | |
| 489 | /* Allow incoming hid reports */ |
| 490 | hid_device_io_start(hdev); |
| 491 | |
| 492 | ret = rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); |
| 493 | if (ret < 0) { |
| 494 | dev_err(&hdev->dev, "failed to set rmi mode\n"); |
| 495 | goto exit; |
| 496 | } |
| 497 | |
| 498 | ret = rmi_set_page(hdev, 0); |
| 499 | if (ret < 0) { |
| 500 | dev_err(&hdev->dev, "failed to set page select to 0.\n"); |
| 501 | goto exit; |
| 502 | } |
| 503 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 504 | ret = rmi_register_transport_device(&data->xport); |
| 505 | if (ret < 0) { |
| 506 | dev_err(&hdev->dev, "failed to register transport driver\n"); |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 507 | goto exit; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | set_bit(RMI_STARTED, &data->flags); |
| 511 | |
| 512 | exit: |
| 513 | hid_device_io_stop(hdev); |
| 514 | hid_hw_close(hdev); |
Dmitry Torokhov | 9154301 | 2015-09-29 15:52:59 -0700 | [diff] [blame] | 515 | return ret; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | static int rmi_input_mapping(struct hid_device *hdev, |
| 519 | struct hid_input *hi, struct hid_field *field, |
| 520 | struct hid_usage *usage, unsigned long **bit, int *max) |
| 521 | { |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 522 | struct rmi_data *data = hid_get_drvdata(hdev); |
| 523 | |
| 524 | /* |
| 525 | * we want to make HID ignore the advertised HID collection |
| 526 | * for RMI deivces |
| 527 | */ |
Andrew Duggan | 79364d8 | 2015-01-08 14:51:34 -0800 | [diff] [blame] | 528 | if (data->device_flags & RMI_DEVICE) { |
| 529 | if ((data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS) && |
| 530 | ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON)) |
| 531 | return 0; |
| 532 | |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 533 | return -1; |
Andrew Duggan | 79364d8 | 2015-01-08 14:51:34 -0800 | [diff] [blame] | 534 | } |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 535 | |
| 536 | return 0; |
| 537 | } |
| 538 | |
| 539 | static int rmi_check_valid_report_id(struct hid_device *hdev, unsigned type, |
| 540 | unsigned id, struct hid_report **report) |
| 541 | { |
| 542 | int i; |
| 543 | |
| 544 | *report = hdev->report_enum[type].report_id_hash[id]; |
| 545 | if (*report) { |
| 546 | for (i = 0; i < (*report)->maxfield; i++) { |
| 547 | unsigned app = (*report)->field[i]->application; |
| 548 | if ((app & HID_USAGE_PAGE) >= HID_UP_MSVENDOR) |
| 549 | return 1; |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | return 0; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 554 | } |
| 555 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 556 | static struct rmi_device_platform_data rmi_hid_pdata = { |
| 557 | .sensor_pdata = { |
| 558 | .sensor_type = rmi_sensor_touchpad, |
| 559 | .axis_align.flip_y = true, |
| 560 | .dribble = RMI_REG_STATE_ON, |
| 561 | .palm_detect = RMI_REG_STATE_OFF, |
| 562 | }, |
| 563 | }; |
| 564 | |
| 565 | static const struct rmi_transport_ops hid_rmi_ops = { |
| 566 | .write_block = rmi_hid_write_block, |
| 567 | .read_block = rmi_hid_read_block, |
| 568 | .reset = rmi_hid_reset, |
| 569 | }; |
| 570 | |
| 571 | static void rmi_irq_teardown(void *data) |
| 572 | { |
| 573 | struct rmi_data *hdata = data; |
| 574 | struct irq_domain *domain = hdata->domain; |
| 575 | |
| 576 | if (!domain) |
| 577 | return; |
| 578 | |
| 579 | irq_dispose_mapping(irq_find_mapping(domain, 0)); |
| 580 | |
| 581 | irq_domain_remove(domain); |
| 582 | hdata->domain = NULL; |
| 583 | hdata->rmi_irq = 0; |
| 584 | } |
| 585 | |
| 586 | static int rmi_irq_map(struct irq_domain *h, unsigned int virq, |
| 587 | irq_hw_number_t hw_irq_num) |
| 588 | { |
| 589 | irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq); |
| 590 | |
| 591 | return 0; |
| 592 | } |
| 593 | |
| 594 | static const struct irq_domain_ops rmi_irq_ops = { |
| 595 | .map = rmi_irq_map, |
| 596 | }; |
| 597 | |
| 598 | static int rmi_setup_irq_domain(struct hid_device *hdev) |
| 599 | { |
| 600 | struct rmi_data *hdata = hid_get_drvdata(hdev); |
| 601 | int ret; |
| 602 | |
| 603 | hdata->domain = irq_domain_create_linear(hdev->dev.fwnode, 1, |
| 604 | &rmi_irq_ops, hdata); |
| 605 | if (!hdata->domain) |
| 606 | return -ENOMEM; |
| 607 | |
| 608 | ret = devm_add_action_or_reset(&hdev->dev, &rmi_irq_teardown, hdata); |
| 609 | if (ret) |
| 610 | return ret; |
| 611 | |
| 612 | hdata->rmi_irq = irq_create_mapping(hdata->domain, 0); |
| 613 | if (hdata->rmi_irq <= 0) { |
| 614 | hid_err(hdev, "Can't allocate an IRQ\n"); |
| 615 | return hdata->rmi_irq < 0 ? hdata->rmi_irq : -ENXIO; |
| 616 | } |
| 617 | |
| 618 | return 0; |
| 619 | } |
| 620 | |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 621 | static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id) |
| 622 | { |
| 623 | struct rmi_data *data = NULL; |
| 624 | int ret; |
| 625 | size_t alloc_size; |
Andrew Duggan | dd3edeb | 2014-07-17 16:14:44 -0700 | [diff] [blame] | 626 | struct hid_report *input_report; |
| 627 | struct hid_report *output_report; |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 628 | struct hid_report *feature_report; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 629 | |
| 630 | data = devm_kzalloc(&hdev->dev, sizeof(struct rmi_data), GFP_KERNEL); |
| 631 | if (!data) |
| 632 | return -ENOMEM; |
| 633 | |
| 634 | INIT_WORK(&data->reset_work, rmi_reset_work); |
| 635 | data->hdev = hdev; |
| 636 | |
| 637 | hid_set_drvdata(hdev, data); |
| 638 | |
| 639 | hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; |
| 640 | |
| 641 | ret = hid_parse(hdev); |
| 642 | if (ret) { |
| 643 | hid_err(hdev, "parse failed\n"); |
| 644 | return ret; |
| 645 | } |
| 646 | |
Andrew Duggan | 79364d8 | 2015-01-08 14:51:34 -0800 | [diff] [blame] | 647 | if (id->driver_data) |
| 648 | data->device_flags = id->driver_data; |
| 649 | |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 650 | /* |
| 651 | * Check for the RMI specific report ids. If they are misisng |
| 652 | * simply return and let the events be processed by hid-input |
| 653 | */ |
| 654 | if (!rmi_check_valid_report_id(hdev, HID_FEATURE_REPORT, |
| 655 | RMI_SET_RMI_MODE_REPORT_ID, &feature_report)) { |
| 656 | hid_dbg(hdev, "device does not have set mode feature report\n"); |
| 657 | goto start; |
| 658 | } |
| 659 | |
| 660 | if (!rmi_check_valid_report_id(hdev, HID_INPUT_REPORT, |
| 661 | RMI_ATTN_REPORT_ID, &input_report)) { |
| 662 | hid_dbg(hdev, "device does not have attention input report\n"); |
| 663 | goto start; |
Andrew Duggan | dd3edeb | 2014-07-17 16:14:44 -0700 | [diff] [blame] | 664 | } |
| 665 | |
Andrew Duggan | b8aed6e | 2015-01-08 14:51:36 -0800 | [diff] [blame] | 666 | data->input_report_size = hid_report_len(input_report); |
Andrew Duggan | dd3edeb | 2014-07-17 16:14:44 -0700 | [diff] [blame] | 667 | |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 668 | if (!rmi_check_valid_report_id(hdev, HID_OUTPUT_REPORT, |
| 669 | RMI_WRITE_REPORT_ID, &output_report)) { |
| 670 | hid_dbg(hdev, |
| 671 | "device does not have rmi write output report\n"); |
| 672 | goto start; |
Andrew Duggan | dd3edeb | 2014-07-17 16:14:44 -0700 | [diff] [blame] | 673 | } |
| 674 | |
Andrew Duggan | b8aed6e | 2015-01-08 14:51:36 -0800 | [diff] [blame] | 675 | data->output_report_size = hid_report_len(output_report); |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 676 | |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 677 | data->device_flags |= RMI_DEVICE; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 678 | alloc_size = data->output_report_size + data->input_report_size; |
| 679 | |
| 680 | data->writeReport = devm_kzalloc(&hdev->dev, alloc_size, GFP_KERNEL); |
| 681 | if (!data->writeReport) { |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 682 | hid_err(hdev, "failed to allocate buffer for HID reports\n"); |
| 683 | return -ENOMEM; |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | data->readReport = data->writeReport + data->output_report_size; |
| 687 | |
| 688 | init_waitqueue_head(&data->wait); |
| 689 | |
| 690 | mutex_init(&data->page_mutex); |
| 691 | |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 692 | ret = rmi_setup_irq_domain(hdev); |
| 693 | if (ret) { |
| 694 | hid_err(hdev, "failed to allocate IRQ domain\n"); |
| 695 | return ret; |
| 696 | } |
| 697 | |
| 698 | if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS) |
| 699 | rmi_hid_pdata.f30_data.disable = true; |
| 700 | |
| 701 | data->xport.dev = hdev->dev.parent; |
| 702 | data->xport.pdata = rmi_hid_pdata; |
| 703 | data->xport.pdata.irq = data->rmi_irq; |
| 704 | data->xport.proto_name = "hid"; |
| 705 | data->xport.ops = &hid_rmi_ops; |
| 706 | |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 707 | start: |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 708 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
| 709 | if (ret) { |
| 710 | hid_err(hdev, "hw start failed\n"); |
| 711 | return ret; |
| 712 | } |
| 713 | |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 714 | return 0; |
| 715 | } |
| 716 | |
| 717 | static void rmi_remove(struct hid_device *hdev) |
| 718 | { |
| 719 | struct rmi_data *hdata = hid_get_drvdata(hdev); |
| 720 | |
Andrew Duggan | ef14a4bf | 2017-10-17 18:37:36 -0700 | [diff] [blame] | 721 | if (hdata->device_flags & RMI_DEVICE) { |
| 722 | clear_bit(RMI_STARTED, &hdata->flags); |
| 723 | cancel_work_sync(&hdata->reset_work); |
| 724 | rmi_unregister_transport_device(&hdata->xport); |
| 725 | } |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 726 | |
| 727 | hid_hw_stop(hdev); |
| 728 | } |
| 729 | |
| 730 | static const struct hid_device_id rmi_id[] = { |
Andrew Duggan | e928709 | 2015-01-08 14:51:35 -0800 | [diff] [blame] | 731 | { HID_USB_DEVICE(USB_VENDOR_ID_RAZER, USB_DEVICE_ID_RAZER_BLADE_14), |
| 732 | .driver_data = RMI_DEVICE_HAS_PHYS_BUTTONS }, |
Andrew Duggan | c7821d0 | 2017-01-05 09:49:00 +0100 | [diff] [blame] | 733 | { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X1_COVER) }, |
Andrew Duggan | c529340 | 2017-11-17 17:21:30 -0800 | [diff] [blame] | 734 | { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_REZEL) }, |
Benjamin Tissoires | ba391e5 | 2014-05-21 11:15:56 -0400 | [diff] [blame] | 735 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_RMI, HID_ANY_ID, HID_ANY_ID) }, |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 736 | { } |
| 737 | }; |
| 738 | MODULE_DEVICE_TABLE(hid, rmi_id); |
| 739 | |
| 740 | static struct hid_driver rmi_driver = { |
| 741 | .name = "hid-rmi", |
| 742 | .id_table = rmi_id, |
| 743 | .probe = rmi_probe, |
| 744 | .remove = rmi_remove, |
Andrew Duggan | 2f43de6 | 2014-12-19 14:45:41 -0800 | [diff] [blame] | 745 | .event = rmi_event, |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 746 | .raw_event = rmi_raw_event, |
| 747 | .input_mapping = rmi_input_mapping, |
| 748 | .input_configured = rmi_input_configured, |
| 749 | #ifdef CONFIG_PM |
Andrew Duggan | 0925636 | 2015-07-06 16:48:31 -0700 | [diff] [blame] | 750 | .suspend = rmi_suspend, |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 751 | .resume = rmi_post_resume, |
Andrew Duggan | 0b2c7a8 | 2017-01-05 09:48:58 +0100 | [diff] [blame] | 752 | .reset_resume = rmi_post_resume, |
Benjamin Tissoires | 9fb6bf0 | 2014-04-07 13:39:33 -0400 | [diff] [blame] | 753 | #endif |
| 754 | }; |
| 755 | |
| 756 | module_hid_driver(rmi_driver); |
| 757 | |
| 758 | MODULE_AUTHOR("Andrew Duggan <aduggan@synaptics.com>"); |
| 759 | MODULE_DESCRIPTION("RMI HID driver"); |
| 760 | MODULE_LICENSE("GPL"); |