hid-cp2112.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227
  1. /*
  2. * hid-cp2112.c - Silicon Labs HID USB to SMBus master bridge
  3. * Copyright (c) 2013,2014 Uplogix, Inc.
  4. * David Barksdale <dbarksdale@uplogix.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. */
  15. /*
  16. * The Silicon Labs CP2112 chip is a USB HID device which provides an
  17. * SMBus controller for talking to slave devices and 8 GPIO pins. The
  18. * host communicates with the CP2112 via raw HID reports.
  19. *
  20. * Data Sheet:
  21. * http://www.silabs.com/Support%20Documents/TechnicalDocs/CP2112.pdf
  22. * Programming Interface Specification:
  23. * http://www.silabs.com/Support%20Documents/TechnicalDocs/AN495.pdf
  24. */
  25. #include <linux/gpio/driver.h>
  26. #include <linux/hid.h>
  27. #include <linux/i2c.h>
  28. #include <linux/module.h>
  29. #include <linux/nls.h>
  30. #include <linux/usb/ch9.h>
  31. #include "hid-ids.h"
  32. enum {
  33. CP2112_GPIO_CONFIG = 0x02,
  34. CP2112_GPIO_GET = 0x03,
  35. CP2112_GPIO_SET = 0x04,
  36. CP2112_GET_VERSION_INFO = 0x05,
  37. CP2112_SMBUS_CONFIG = 0x06,
  38. CP2112_DATA_READ_REQUEST = 0x10,
  39. CP2112_DATA_WRITE_READ_REQUEST = 0x11,
  40. CP2112_DATA_READ_FORCE_SEND = 0x12,
  41. CP2112_DATA_READ_RESPONSE = 0x13,
  42. CP2112_DATA_WRITE_REQUEST = 0x14,
  43. CP2112_TRANSFER_STATUS_REQUEST = 0x15,
  44. CP2112_TRANSFER_STATUS_RESPONSE = 0x16,
  45. CP2112_CANCEL_TRANSFER = 0x17,
  46. CP2112_LOCK_BYTE = 0x20,
  47. CP2112_USB_CONFIG = 0x21,
  48. CP2112_MANUFACTURER_STRING = 0x22,
  49. CP2112_PRODUCT_STRING = 0x23,
  50. CP2112_SERIAL_STRING = 0x24,
  51. };
  52. enum {
  53. STATUS0_IDLE = 0x00,
  54. STATUS0_BUSY = 0x01,
  55. STATUS0_COMPLETE = 0x02,
  56. STATUS0_ERROR = 0x03,
  57. };
  58. enum {
  59. STATUS1_TIMEOUT_NACK = 0x00,
  60. STATUS1_TIMEOUT_BUS = 0x01,
  61. STATUS1_ARBITRATION_LOST = 0x02,
  62. STATUS1_READ_INCOMPLETE = 0x03,
  63. STATUS1_WRITE_INCOMPLETE = 0x04,
  64. STATUS1_SUCCESS = 0x05,
  65. };
  66. struct cp2112_smbus_config_report {
  67. u8 report; /* CP2112_SMBUS_CONFIG */
  68. __be32 clock_speed; /* Hz */
  69. u8 device_address; /* Stored in the upper 7 bits */
  70. u8 auto_send_read; /* 1 = enabled, 0 = disabled */
  71. __be16 write_timeout; /* ms, 0 = no timeout */
  72. __be16 read_timeout; /* ms, 0 = no timeout */
  73. u8 scl_low_timeout; /* 1 = enabled, 0 = disabled */
  74. __be16 retry_time; /* # of retries, 0 = no limit */
  75. } __packed;
  76. struct cp2112_usb_config_report {
  77. u8 report; /* CP2112_USB_CONFIG */
  78. __le16 vid; /* Vendor ID */
  79. __le16 pid; /* Product ID */
  80. u8 max_power; /* Power requested in 2mA units */
  81. u8 power_mode; /* 0x00 = bus powered
  82. 0x01 = self powered & regulator off
  83. 0x02 = self powered & regulator on */
  84. u8 release_major;
  85. u8 release_minor;
  86. u8 mask; /* What fields to program */
  87. } __packed;
  88. struct cp2112_read_req_report {
  89. u8 report; /* CP2112_DATA_READ_REQUEST */
  90. u8 slave_address;
  91. __be16 length;
  92. } __packed;
  93. struct cp2112_write_read_req_report {
  94. u8 report; /* CP2112_DATA_WRITE_READ_REQUEST */
  95. u8 slave_address;
  96. __be16 length;
  97. u8 target_address_length;
  98. u8 target_address[16];
  99. } __packed;
  100. struct cp2112_write_req_report {
  101. u8 report; /* CP2112_DATA_WRITE_REQUEST */
  102. u8 slave_address;
  103. u8 length;
  104. u8 data[61];
  105. } __packed;
  106. struct cp2112_force_read_report {
  107. u8 report; /* CP2112_DATA_READ_FORCE_SEND */
  108. __be16 length;
  109. } __packed;
  110. struct cp2112_xfer_status_report {
  111. u8 report; /* CP2112_TRANSFER_STATUS_RESPONSE */
  112. u8 status0; /* STATUS0_* */
  113. u8 status1; /* STATUS1_* */
  114. __be16 retries;
  115. __be16 length;
  116. } __packed;
  117. struct cp2112_string_report {
  118. u8 dummy; /* force .string to be aligned */
  119. u8 report; /* CP2112_*_STRING */
  120. u8 length; /* length in bytes of everyting after .report */
  121. u8 type; /* USB_DT_STRING */
  122. wchar_t string[30]; /* UTF16_LITTLE_ENDIAN string */
  123. } __packed;
  124. /* Number of times to request transfer status before giving up waiting for a
  125. transfer to complete. This may need to be changed if SMBUS clock, retries,
  126. or read/write/scl_low timeout settings are changed. */
  127. static const int XFER_STATUS_RETRIES = 10;
  128. /* Time in ms to wait for a CP2112_DATA_READ_RESPONSE or
  129. CP2112_TRANSFER_STATUS_RESPONSE. */
  130. static const int RESPONSE_TIMEOUT = 50;
  131. static const struct hid_device_id cp2112_devices[] = {
  132. { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) },
  133. { }
  134. };
  135. MODULE_DEVICE_TABLE(hid, cp2112_devices);
  136. struct cp2112_device {
  137. struct i2c_adapter adap;
  138. struct hid_device *hdev;
  139. wait_queue_head_t wait;
  140. u8 read_data[61];
  141. u8 read_length;
  142. u8 hwversion;
  143. int xfer_status;
  144. atomic_t read_avail;
  145. atomic_t xfer_avail;
  146. struct gpio_chip gc;
  147. };
  148. static int gpio_push_pull = 0xFF;
  149. module_param(gpio_push_pull, int, S_IRUGO | S_IWUSR);
  150. MODULE_PARM_DESC(gpio_push_pull, "GPIO push-pull configuration bitmask");
  151. static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
  152. {
  153. struct cp2112_device *dev = gpiochip_get_data(chip);
  154. struct hid_device *hdev = dev->hdev;
  155. u8 buf[5];
  156. int ret;
  157. ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
  158. sizeof(buf), HID_FEATURE_REPORT,
  159. HID_REQ_GET_REPORT);
  160. if (ret != sizeof(buf)) {
  161. hid_err(hdev, "error requesting GPIO config: %d\n", ret);
  162. return ret;
  163. }
  164. buf[1] &= ~(1 << offset);
  165. buf[2] = gpio_push_pull;
  166. ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, sizeof(buf),
  167. HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
  168. if (ret < 0) {
  169. hid_err(hdev, "error setting GPIO config: %d\n", ret);
  170. return ret;
  171. }
  172. return 0;
  173. }
  174. static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  175. {
  176. struct cp2112_device *dev = gpiochip_get_data(chip);
  177. struct hid_device *hdev = dev->hdev;
  178. u8 buf[3];
  179. int ret;
  180. buf[0] = CP2112_GPIO_SET;
  181. buf[1] = value ? 0xff : 0;
  182. buf[2] = 1 << offset;
  183. ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf, sizeof(buf),
  184. HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
  185. if (ret < 0)
  186. hid_err(hdev, "error setting GPIO values: %d\n", ret);
  187. }
  188. static int cp2112_gpio_get(struct gpio_chip *chip, unsigned offset)
  189. {
  190. struct cp2112_device *dev = gpiochip_get_data(chip);
  191. struct hid_device *hdev = dev->hdev;
  192. u8 buf[2];
  193. int ret;
  194. ret = hid_hw_raw_request(hdev, CP2112_GPIO_GET, buf, sizeof(buf),
  195. HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
  196. if (ret != sizeof(buf)) {
  197. hid_err(hdev, "error requesting GPIO values: %d\n", ret);
  198. return ret;
  199. }
  200. return (buf[1] >> offset) & 1;
  201. }
  202. static int cp2112_gpio_direction_output(struct gpio_chip *chip,
  203. unsigned offset, int value)
  204. {
  205. struct cp2112_device *dev = gpiochip_get_data(chip);
  206. struct hid_device *hdev = dev->hdev;
  207. u8 buf[5];
  208. int ret;
  209. ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
  210. sizeof(buf), HID_FEATURE_REPORT,
  211. HID_REQ_GET_REPORT);
  212. if (ret != sizeof(buf)) {
  213. hid_err(hdev, "error requesting GPIO config: %d\n", ret);
  214. return ret;
  215. }
  216. buf[1] |= 1 << offset;
  217. buf[2] = gpio_push_pull;
  218. ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, sizeof(buf),
  219. HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
  220. if (ret < 0) {
  221. hid_err(hdev, "error setting GPIO config: %d\n", ret);
  222. return ret;
  223. }
  224. /*
  225. * Set gpio value when output direction is already set,
  226. * as specified in AN495, Rev. 0.2, cpt. 4.4
  227. */
  228. cp2112_gpio_set(chip, offset, value);
  229. return 0;
  230. }
  231. static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number,
  232. u8 *data, size_t count, unsigned char report_type)
  233. {
  234. u8 *buf;
  235. int ret;
  236. buf = kmalloc(count, GFP_KERNEL);
  237. if (!buf)
  238. return -ENOMEM;
  239. ret = hid_hw_raw_request(hdev, report_number, buf, count,
  240. report_type, HID_REQ_GET_REPORT);
  241. memcpy(data, buf, count);
  242. kfree(buf);
  243. return ret;
  244. }
  245. static int cp2112_hid_output(struct hid_device *hdev, u8 *data, size_t count,
  246. unsigned char report_type)
  247. {
  248. u8 *buf;
  249. int ret;
  250. buf = kmemdup(data, count, GFP_KERNEL);
  251. if (!buf)
  252. return -ENOMEM;
  253. if (report_type == HID_OUTPUT_REPORT)
  254. ret = hid_hw_output_report(hdev, buf, count);
  255. else
  256. ret = hid_hw_raw_request(hdev, buf[0], buf, count, report_type,
  257. HID_REQ_SET_REPORT);
  258. kfree(buf);
  259. return ret;
  260. }
  261. static int cp2112_wait(struct cp2112_device *dev, atomic_t *avail)
  262. {
  263. int ret = 0;
  264. /* We have sent either a CP2112_TRANSFER_STATUS_REQUEST or a
  265. * CP2112_DATA_READ_FORCE_SEND and we are waiting for the response to
  266. * come in cp2112_raw_event or timeout. There will only be one of these
  267. * in flight at any one time. The timeout is extremely large and is a
  268. * last resort if the CP2112 has died. If we do timeout we don't expect
  269. * to receive the response which would cause data races, it's not like
  270. * we can do anything about it anyway.
  271. */
  272. ret = wait_event_interruptible_timeout(dev->wait,
  273. atomic_read(avail), msecs_to_jiffies(RESPONSE_TIMEOUT));
  274. if (-ERESTARTSYS == ret)
  275. return ret;
  276. if (!ret)
  277. return -ETIMEDOUT;
  278. atomic_set(avail, 0);
  279. return 0;
  280. }
  281. static int cp2112_xfer_status(struct cp2112_device *dev)
  282. {
  283. struct hid_device *hdev = dev->hdev;
  284. u8 buf[2];
  285. int ret;
  286. buf[0] = CP2112_TRANSFER_STATUS_REQUEST;
  287. buf[1] = 0x01;
  288. atomic_set(&dev->xfer_avail, 0);
  289. ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT);
  290. if (ret < 0) {
  291. hid_warn(hdev, "Error requesting status: %d\n", ret);
  292. return ret;
  293. }
  294. ret = cp2112_wait(dev, &dev->xfer_avail);
  295. if (ret)
  296. return ret;
  297. return dev->xfer_status;
  298. }
  299. static int cp2112_read(struct cp2112_device *dev, u8 *data, size_t size)
  300. {
  301. struct hid_device *hdev = dev->hdev;
  302. struct cp2112_force_read_report report;
  303. int ret;
  304. if (size > sizeof(dev->read_data))
  305. size = sizeof(dev->read_data);
  306. report.report = CP2112_DATA_READ_FORCE_SEND;
  307. report.length = cpu_to_be16(size);
  308. atomic_set(&dev->read_avail, 0);
  309. ret = cp2112_hid_output(hdev, &report.report, sizeof(report),
  310. HID_OUTPUT_REPORT);
  311. if (ret < 0) {
  312. hid_warn(hdev, "Error requesting data: %d\n", ret);
  313. return ret;
  314. }
  315. ret = cp2112_wait(dev, &dev->read_avail);
  316. if (ret)
  317. return ret;
  318. hid_dbg(hdev, "read %d of %zd bytes requested\n",
  319. dev->read_length, size);
  320. if (size > dev->read_length)
  321. size = dev->read_length;
  322. memcpy(data, dev->read_data, size);
  323. return dev->read_length;
  324. }
  325. static int cp2112_read_req(void *buf, u8 slave_address, u16 length)
  326. {
  327. struct cp2112_read_req_report *report = buf;
  328. if (length < 1 || length > 512)
  329. return -EINVAL;
  330. report->report = CP2112_DATA_READ_REQUEST;
  331. report->slave_address = slave_address << 1;
  332. report->length = cpu_to_be16(length);
  333. return sizeof(*report);
  334. }
  335. static int cp2112_write_read_req(void *buf, u8 slave_address, u16 length,
  336. u8 command, u8 *data, u8 data_length)
  337. {
  338. struct cp2112_write_read_req_report *report = buf;
  339. if (length < 1 || length > 512
  340. || data_length > sizeof(report->target_address) - 1)
  341. return -EINVAL;
  342. report->report = CP2112_DATA_WRITE_READ_REQUEST;
  343. report->slave_address = slave_address << 1;
  344. report->length = cpu_to_be16(length);
  345. report->target_address_length = data_length + 1;
  346. report->target_address[0] = command;
  347. memcpy(&report->target_address[1], data, data_length);
  348. return data_length + 6;
  349. }
  350. static int cp2112_write_req(void *buf, u8 slave_address, u8 command, u8 *data,
  351. u8 data_length)
  352. {
  353. struct cp2112_write_req_report *report = buf;
  354. if (data_length > sizeof(report->data) - 1)
  355. return -EINVAL;
  356. report->report = CP2112_DATA_WRITE_REQUEST;
  357. report->slave_address = slave_address << 1;
  358. report->length = data_length + 1;
  359. report->data[0] = command;
  360. memcpy(&report->data[1], data, data_length);
  361. return data_length + 4;
  362. }
  363. static int cp2112_i2c_write_req(void *buf, u8 slave_address, u8 *data,
  364. u8 data_length)
  365. {
  366. struct cp2112_write_req_report *report = buf;
  367. if (data_length > sizeof(report->data))
  368. return -EINVAL;
  369. report->report = CP2112_DATA_WRITE_REQUEST;
  370. report->slave_address = slave_address << 1;
  371. report->length = data_length;
  372. memcpy(report->data, data, data_length);
  373. return data_length + 3;
  374. }
  375. static int cp2112_i2c_write_read_req(void *buf, u8 slave_address,
  376. u8 *addr, int addr_length,
  377. int read_length)
  378. {
  379. struct cp2112_write_read_req_report *report = buf;
  380. if (read_length < 1 || read_length > 512 ||
  381. addr_length > sizeof(report->target_address))
  382. return -EINVAL;
  383. report->report = CP2112_DATA_WRITE_READ_REQUEST;
  384. report->slave_address = slave_address << 1;
  385. report->length = cpu_to_be16(read_length);
  386. report->target_address_length = addr_length;
  387. memcpy(report->target_address, addr, addr_length);
  388. return addr_length + 5;
  389. }
  390. static int cp2112_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
  391. int num)
  392. {
  393. struct cp2112_device *dev = (struct cp2112_device *)adap->algo_data;
  394. struct hid_device *hdev = dev->hdev;
  395. u8 buf[64];
  396. ssize_t count;
  397. ssize_t read_length = 0;
  398. u8 *read_buf = NULL;
  399. unsigned int retries;
  400. int ret;
  401. hid_dbg(hdev, "I2C %d messages\n", num);
  402. if (num == 1) {
  403. if (msgs->flags & I2C_M_RD) {
  404. hid_dbg(hdev, "I2C read %#04x len %d\n",
  405. msgs->addr, msgs->len);
  406. read_length = msgs->len;
  407. read_buf = msgs->buf;
  408. count = cp2112_read_req(buf, msgs->addr, msgs->len);
  409. } else {
  410. hid_dbg(hdev, "I2C write %#04x len %d\n",
  411. msgs->addr, msgs->len);
  412. count = cp2112_i2c_write_req(buf, msgs->addr,
  413. msgs->buf, msgs->len);
  414. }
  415. if (count < 0)
  416. return count;
  417. } else if (dev->hwversion > 1 && /* no repeated start in rev 1 */
  418. num == 2 &&
  419. msgs[0].addr == msgs[1].addr &&
  420. !(msgs[0].flags & I2C_M_RD) && (msgs[1].flags & I2C_M_RD)) {
  421. hid_dbg(hdev, "I2C write-read %#04x wlen %d rlen %d\n",
  422. msgs[0].addr, msgs[0].len, msgs[1].len);
  423. read_length = msgs[1].len;
  424. read_buf = msgs[1].buf;
  425. count = cp2112_i2c_write_read_req(buf, msgs[0].addr,
  426. msgs[0].buf, msgs[0].len, msgs[1].len);
  427. if (count < 0)
  428. return count;
  429. } else {
  430. hid_err(hdev,
  431. "Multi-message I2C transactions not supported\n");
  432. return -EOPNOTSUPP;
  433. }
  434. ret = hid_hw_power(hdev, PM_HINT_FULLON);
  435. if (ret < 0) {
  436. hid_err(hdev, "power management error: %d\n", ret);
  437. return ret;
  438. }
  439. ret = cp2112_hid_output(hdev, buf, count, HID_OUTPUT_REPORT);
  440. if (ret < 0) {
  441. hid_warn(hdev, "Error starting transaction: %d\n", ret);
  442. goto power_normal;
  443. }
  444. for (retries = 0; retries < XFER_STATUS_RETRIES; ++retries) {
  445. ret = cp2112_xfer_status(dev);
  446. if (-EBUSY == ret)
  447. continue;
  448. if (ret < 0)
  449. goto power_normal;
  450. break;
  451. }
  452. if (XFER_STATUS_RETRIES <= retries) {
  453. hid_warn(hdev, "Transfer timed out, cancelling.\n");
  454. buf[0] = CP2112_CANCEL_TRANSFER;
  455. buf[1] = 0x01;
  456. ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT);
  457. if (ret < 0)
  458. hid_warn(hdev, "Error cancelling transaction: %d\n",
  459. ret);
  460. ret = -ETIMEDOUT;
  461. goto power_normal;
  462. }
  463. for (count = 0; count < read_length;) {
  464. ret = cp2112_read(dev, read_buf + count, read_length - count);
  465. if (ret < 0)
  466. goto power_normal;
  467. if (ret == 0) {
  468. hid_err(hdev, "read returned 0\n");
  469. ret = -EIO;
  470. goto power_normal;
  471. }
  472. count += ret;
  473. if (count > read_length) {
  474. /*
  475. * The hardware returned too much data.
  476. * This is mostly harmless because cp2112_read()
  477. * has a limit check so didn't overrun our
  478. * buffer. Nevertheless, we return an error
  479. * because something is seriously wrong and
  480. * it shouldn't go unnoticed.
  481. */
  482. hid_err(hdev, "long read: %d > %zd\n",
  483. ret, read_length - count + ret);
  484. ret = -EIO;
  485. goto power_normal;
  486. }
  487. }
  488. /* return the number of transferred messages */
  489. ret = num;
  490. power_normal:
  491. hid_hw_power(hdev, PM_HINT_NORMAL);
  492. hid_dbg(hdev, "I2C transfer finished: %d\n", ret);
  493. return ret;
  494. }
  495. static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
  496. unsigned short flags, char read_write, u8 command,
  497. int size, union i2c_smbus_data *data)
  498. {
  499. struct cp2112_device *dev = (struct cp2112_device *)adap->algo_data;
  500. struct hid_device *hdev = dev->hdev;
  501. u8 buf[64];
  502. __le16 word;
  503. ssize_t count;
  504. size_t read_length = 0;
  505. unsigned int retries;
  506. int ret;
  507. hid_dbg(hdev, "%s addr 0x%x flags 0x%x cmd 0x%x size %d\n",
  508. read_write == I2C_SMBUS_WRITE ? "write" : "read",
  509. addr, flags, command, size);
  510. switch (size) {
  511. case I2C_SMBUS_BYTE:
  512. read_length = 1;
  513. if (I2C_SMBUS_READ == read_write)
  514. count = cp2112_read_req(buf, addr, read_length);
  515. else
  516. count = cp2112_write_req(buf, addr, command, NULL,
  517. 0);
  518. break;
  519. case I2C_SMBUS_BYTE_DATA:
  520. read_length = 1;
  521. if (I2C_SMBUS_READ == read_write)
  522. count = cp2112_write_read_req(buf, addr, read_length,
  523. command, NULL, 0);
  524. else
  525. count = cp2112_write_req(buf, addr, command,
  526. &data->byte, 1);
  527. break;
  528. case I2C_SMBUS_WORD_DATA:
  529. read_length = 2;
  530. word = cpu_to_le16(data->word);
  531. if (I2C_SMBUS_READ == read_write)
  532. count = cp2112_write_read_req(buf, addr, read_length,
  533. command, NULL, 0);
  534. else
  535. count = cp2112_write_req(buf, addr, command,
  536. (u8 *)&word, 2);
  537. break;
  538. case I2C_SMBUS_PROC_CALL:
  539. size = I2C_SMBUS_WORD_DATA;
  540. read_write = I2C_SMBUS_READ;
  541. read_length = 2;
  542. word = cpu_to_le16(data->word);
  543. count = cp2112_write_read_req(buf, addr, read_length, command,
  544. (u8 *)&word, 2);
  545. break;
  546. case I2C_SMBUS_I2C_BLOCK_DATA:
  547. size = I2C_SMBUS_BLOCK_DATA;
  548. /* fallthrough */
  549. case I2C_SMBUS_BLOCK_DATA:
  550. if (I2C_SMBUS_READ == read_write) {
  551. count = cp2112_write_read_req(buf, addr,
  552. I2C_SMBUS_BLOCK_MAX,
  553. command, NULL, 0);
  554. } else {
  555. count = cp2112_write_req(buf, addr, command,
  556. data->block,
  557. data->block[0] + 1);
  558. }
  559. break;
  560. case I2C_SMBUS_BLOCK_PROC_CALL:
  561. size = I2C_SMBUS_BLOCK_DATA;
  562. read_write = I2C_SMBUS_READ;
  563. count = cp2112_write_read_req(buf, addr, I2C_SMBUS_BLOCK_MAX,
  564. command, data->block,
  565. data->block[0] + 1);
  566. break;
  567. default:
  568. hid_warn(hdev, "Unsupported transaction %d\n", size);
  569. return -EOPNOTSUPP;
  570. }
  571. if (count < 0)
  572. return count;
  573. ret = hid_hw_power(hdev, PM_HINT_FULLON);
  574. if (ret < 0) {
  575. hid_err(hdev, "power management error: %d\n", ret);
  576. return ret;
  577. }
  578. ret = cp2112_hid_output(hdev, buf, count, HID_OUTPUT_REPORT);
  579. if (ret < 0) {
  580. hid_warn(hdev, "Error starting transaction: %d\n", ret);
  581. goto power_normal;
  582. }
  583. for (retries = 0; retries < XFER_STATUS_RETRIES; ++retries) {
  584. ret = cp2112_xfer_status(dev);
  585. if (-EBUSY == ret)
  586. continue;
  587. if (ret < 0)
  588. goto power_normal;
  589. break;
  590. }
  591. if (XFER_STATUS_RETRIES <= retries) {
  592. hid_warn(hdev, "Transfer timed out, cancelling.\n");
  593. buf[0] = CP2112_CANCEL_TRANSFER;
  594. buf[1] = 0x01;
  595. ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT);
  596. if (ret < 0)
  597. hid_warn(hdev, "Error cancelling transaction: %d\n",
  598. ret);
  599. ret = -ETIMEDOUT;
  600. goto power_normal;
  601. }
  602. if (I2C_SMBUS_WRITE == read_write) {
  603. ret = 0;
  604. goto power_normal;
  605. }
  606. if (I2C_SMBUS_BLOCK_DATA == size)
  607. read_length = ret;
  608. ret = cp2112_read(dev, buf, read_length);
  609. if (ret < 0)
  610. goto power_normal;
  611. if (ret != read_length) {
  612. hid_warn(hdev, "short read: %d < %zd\n", ret, read_length);
  613. ret = -EIO;
  614. goto power_normal;
  615. }
  616. switch (size) {
  617. case I2C_SMBUS_BYTE:
  618. case I2C_SMBUS_BYTE_DATA:
  619. data->byte = buf[0];
  620. break;
  621. case I2C_SMBUS_WORD_DATA:
  622. data->word = le16_to_cpup((__le16 *)buf);
  623. break;
  624. case I2C_SMBUS_BLOCK_DATA:
  625. if (read_length > I2C_SMBUS_BLOCK_MAX) {
  626. ret = -EPROTO;
  627. goto power_normal;
  628. }
  629. memcpy(data->block, buf, read_length);
  630. break;
  631. }
  632. ret = 0;
  633. power_normal:
  634. hid_hw_power(hdev, PM_HINT_NORMAL);
  635. hid_dbg(hdev, "transfer finished: %d\n", ret);
  636. return ret;
  637. }
  638. static u32 cp2112_functionality(struct i2c_adapter *adap)
  639. {
  640. return I2C_FUNC_I2C |
  641. I2C_FUNC_SMBUS_BYTE |
  642. I2C_FUNC_SMBUS_BYTE_DATA |
  643. I2C_FUNC_SMBUS_WORD_DATA |
  644. I2C_FUNC_SMBUS_BLOCK_DATA |
  645. I2C_FUNC_SMBUS_I2C_BLOCK |
  646. I2C_FUNC_SMBUS_PROC_CALL |
  647. I2C_FUNC_SMBUS_BLOCK_PROC_CALL;
  648. }
  649. static const struct i2c_algorithm smbus_algorithm = {
  650. .master_xfer = cp2112_i2c_xfer,
  651. .smbus_xfer = cp2112_xfer,
  652. .functionality = cp2112_functionality,
  653. };
  654. static int cp2112_get_usb_config(struct hid_device *hdev,
  655. struct cp2112_usb_config_report *cfg)
  656. {
  657. int ret;
  658. ret = cp2112_hid_get(hdev, CP2112_USB_CONFIG, (u8 *)cfg, sizeof(*cfg),
  659. HID_FEATURE_REPORT);
  660. if (ret != sizeof(*cfg)) {
  661. hid_err(hdev, "error reading usb config: %d\n", ret);
  662. if (ret < 0)
  663. return ret;
  664. return -EIO;
  665. }
  666. return 0;
  667. }
  668. static int cp2112_set_usb_config(struct hid_device *hdev,
  669. struct cp2112_usb_config_report *cfg)
  670. {
  671. int ret;
  672. BUG_ON(cfg->report != CP2112_USB_CONFIG);
  673. ret = cp2112_hid_output(hdev, (u8 *)cfg, sizeof(*cfg),
  674. HID_FEATURE_REPORT);
  675. if (ret != sizeof(*cfg)) {
  676. hid_err(hdev, "error writing usb config: %d\n", ret);
  677. if (ret < 0)
  678. return ret;
  679. return -EIO;
  680. }
  681. return 0;
  682. }
  683. static void chmod_sysfs_attrs(struct hid_device *hdev);
  684. #define CP2112_CONFIG_ATTR(name, store, format, ...) \
  685. static ssize_t name##_store(struct device *kdev, \
  686. struct device_attribute *attr, const char *buf, \
  687. size_t count) \
  688. { \
  689. struct hid_device *hdev = to_hid_device(kdev); \
  690. struct cp2112_usb_config_report cfg; \
  691. int ret = cp2112_get_usb_config(hdev, &cfg); \
  692. if (ret) \
  693. return ret; \
  694. store; \
  695. ret = cp2112_set_usb_config(hdev, &cfg); \
  696. if (ret) \
  697. return ret; \
  698. chmod_sysfs_attrs(hdev); \
  699. return count; \
  700. } \
  701. static ssize_t name##_show(struct device *kdev, \
  702. struct device_attribute *attr, char *buf) \
  703. { \
  704. struct hid_device *hdev = to_hid_device(kdev); \
  705. struct cp2112_usb_config_report cfg; \
  706. int ret = cp2112_get_usb_config(hdev, &cfg); \
  707. if (ret) \
  708. return ret; \
  709. return scnprintf(buf, PAGE_SIZE, format, ##__VA_ARGS__); \
  710. } \
  711. static DEVICE_ATTR_RW(name);
  712. CP2112_CONFIG_ATTR(vendor_id, ({
  713. u16 vid;
  714. if (sscanf(buf, "%hi", &vid) != 1)
  715. return -EINVAL;
  716. cfg.vid = cpu_to_le16(vid);
  717. cfg.mask = 0x01;
  718. }), "0x%04x\n", le16_to_cpu(cfg.vid));
  719. CP2112_CONFIG_ATTR(product_id, ({
  720. u16 pid;
  721. if (sscanf(buf, "%hi", &pid) != 1)
  722. return -EINVAL;
  723. cfg.pid = cpu_to_le16(pid);
  724. cfg.mask = 0x02;
  725. }), "0x%04x\n", le16_to_cpu(cfg.pid));
  726. CP2112_CONFIG_ATTR(max_power, ({
  727. int mA;
  728. if (sscanf(buf, "%i", &mA) != 1)
  729. return -EINVAL;
  730. cfg.max_power = (mA + 1) / 2;
  731. cfg.mask = 0x04;
  732. }), "%u mA\n", cfg.max_power * 2);
  733. CP2112_CONFIG_ATTR(power_mode, ({
  734. if (sscanf(buf, "%hhi", &cfg.power_mode) != 1)
  735. return -EINVAL;
  736. cfg.mask = 0x08;
  737. }), "%u\n", cfg.power_mode);
  738. CP2112_CONFIG_ATTR(release_version, ({
  739. if (sscanf(buf, "%hhi.%hhi", &cfg.release_major, &cfg.release_minor)
  740. != 2)
  741. return -EINVAL;
  742. cfg.mask = 0x10;
  743. }), "%u.%u\n", cfg.release_major, cfg.release_minor);
  744. #undef CP2112_CONFIG_ATTR
  745. struct cp2112_pstring_attribute {
  746. struct device_attribute attr;
  747. unsigned char report;
  748. };
  749. static ssize_t pstr_store(struct device *kdev,
  750. struct device_attribute *kattr, const char *buf,
  751. size_t count)
  752. {
  753. struct hid_device *hdev = to_hid_device(kdev);
  754. struct cp2112_pstring_attribute *attr =
  755. container_of(kattr, struct cp2112_pstring_attribute, attr);
  756. struct cp2112_string_report report;
  757. int ret;
  758. memset(&report, 0, sizeof(report));
  759. ret = utf8s_to_utf16s(buf, count, UTF16_LITTLE_ENDIAN,
  760. report.string, ARRAY_SIZE(report.string));
  761. report.report = attr->report;
  762. report.length = ret * sizeof(report.string[0]) + 2;
  763. report.type = USB_DT_STRING;
  764. ret = cp2112_hid_output(hdev, &report.report, report.length + 1,
  765. HID_FEATURE_REPORT);
  766. if (ret != report.length + 1) {
  767. hid_err(hdev, "error writing %s string: %d\n", kattr->attr.name,
  768. ret);
  769. if (ret < 0)
  770. return ret;
  771. return -EIO;
  772. }
  773. chmod_sysfs_attrs(hdev);
  774. return count;
  775. }
  776. static ssize_t pstr_show(struct device *kdev,
  777. struct device_attribute *kattr, char *buf)
  778. {
  779. struct hid_device *hdev = to_hid_device(kdev);
  780. struct cp2112_pstring_attribute *attr =
  781. container_of(kattr, struct cp2112_pstring_attribute, attr);
  782. struct cp2112_string_report report;
  783. u8 length;
  784. int ret;
  785. ret = cp2112_hid_get(hdev, attr->report, &report.report,
  786. sizeof(report) - 1, HID_FEATURE_REPORT);
  787. if (ret < 3) {
  788. hid_err(hdev, "error reading %s string: %d\n", kattr->attr.name,
  789. ret);
  790. if (ret < 0)
  791. return ret;
  792. return -EIO;
  793. }
  794. if (report.length < 2) {
  795. hid_err(hdev, "invalid %s string length: %d\n",
  796. kattr->attr.name, report.length);
  797. return -EIO;
  798. }
  799. length = report.length > ret - 1 ? ret - 1 : report.length;
  800. length = (length - 2) / sizeof(report.string[0]);
  801. ret = utf16s_to_utf8s(report.string, length, UTF16_LITTLE_ENDIAN, buf,
  802. PAGE_SIZE - 1);
  803. buf[ret++] = '\n';
  804. return ret;
  805. }
  806. #define CP2112_PSTR_ATTR(name, _report) \
  807. static struct cp2112_pstring_attribute dev_attr_##name = { \
  808. .attr = __ATTR(name, (S_IWUSR | S_IRUGO), pstr_show, pstr_store), \
  809. .report = _report, \
  810. };
  811. CP2112_PSTR_ATTR(manufacturer, CP2112_MANUFACTURER_STRING);
  812. CP2112_PSTR_ATTR(product, CP2112_PRODUCT_STRING);
  813. CP2112_PSTR_ATTR(serial, CP2112_SERIAL_STRING);
  814. #undef CP2112_PSTR_ATTR
  815. static const struct attribute_group cp2112_attr_group = {
  816. .attrs = (struct attribute *[]){
  817. &dev_attr_vendor_id.attr,
  818. &dev_attr_product_id.attr,
  819. &dev_attr_max_power.attr,
  820. &dev_attr_power_mode.attr,
  821. &dev_attr_release_version.attr,
  822. &dev_attr_manufacturer.attr.attr,
  823. &dev_attr_product.attr.attr,
  824. &dev_attr_serial.attr.attr,
  825. NULL
  826. }
  827. };
  828. /* Chmoding our sysfs attributes is simply a way to expose which fields in the
  829. * PROM have already been programmed. We do not depend on this preventing
  830. * writing to these attributes since the CP2112 will simply ignore writes to
  831. * already-programmed fields. This is why there is no sense in fixing this
  832. * racy behaviour.
  833. */
  834. static void chmod_sysfs_attrs(struct hid_device *hdev)
  835. {
  836. struct attribute **attr;
  837. u8 buf[2];
  838. int ret;
  839. ret = cp2112_hid_get(hdev, CP2112_LOCK_BYTE, buf, sizeof(buf),
  840. HID_FEATURE_REPORT);
  841. if (ret != sizeof(buf)) {
  842. hid_err(hdev, "error reading lock byte: %d\n", ret);
  843. return;
  844. }
  845. for (attr = cp2112_attr_group.attrs; *attr; ++attr) {
  846. umode_t mode = (buf[1] & 1) ? S_IWUSR | S_IRUGO : S_IRUGO;
  847. ret = sysfs_chmod_file(&hdev->dev.kobj, *attr, mode);
  848. if (ret < 0)
  849. hid_err(hdev, "error chmoding sysfs file %s\n",
  850. (*attr)->name);
  851. buf[1] >>= 1;
  852. }
  853. }
  854. static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
  855. {
  856. struct cp2112_device *dev;
  857. u8 buf[3];
  858. struct cp2112_smbus_config_report config;
  859. int ret;
  860. ret = hid_parse(hdev);
  861. if (ret) {
  862. hid_err(hdev, "parse failed\n");
  863. return ret;
  864. }
  865. ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
  866. if (ret) {
  867. hid_err(hdev, "hw start failed\n");
  868. return ret;
  869. }
  870. ret = hid_hw_open(hdev);
  871. if (ret) {
  872. hid_err(hdev, "hw open failed\n");
  873. goto err_hid_stop;
  874. }
  875. ret = hid_hw_power(hdev, PM_HINT_FULLON);
  876. if (ret < 0) {
  877. hid_err(hdev, "power management error: %d\n", ret);
  878. goto err_hid_close;
  879. }
  880. ret = cp2112_hid_get(hdev, CP2112_GET_VERSION_INFO, buf, sizeof(buf),
  881. HID_FEATURE_REPORT);
  882. if (ret != sizeof(buf)) {
  883. hid_err(hdev, "error requesting version\n");
  884. if (ret >= 0)
  885. ret = -EIO;
  886. goto err_power_normal;
  887. }
  888. hid_info(hdev, "Part Number: 0x%02X Device Version: 0x%02X\n",
  889. buf[1], buf[2]);
  890. ret = cp2112_hid_get(hdev, CP2112_SMBUS_CONFIG, (u8 *)&config,
  891. sizeof(config), HID_FEATURE_REPORT);
  892. if (ret != sizeof(config)) {
  893. hid_err(hdev, "error requesting SMBus config\n");
  894. if (ret >= 0)
  895. ret = -EIO;
  896. goto err_power_normal;
  897. }
  898. config.retry_time = cpu_to_be16(1);
  899. ret = cp2112_hid_output(hdev, (u8 *)&config, sizeof(config),
  900. HID_FEATURE_REPORT);
  901. if (ret != sizeof(config)) {
  902. hid_err(hdev, "error setting SMBus config\n");
  903. if (ret >= 0)
  904. ret = -EIO;
  905. goto err_power_normal;
  906. }
  907. dev = kzalloc(sizeof(*dev), GFP_KERNEL);
  908. if (!dev) {
  909. ret = -ENOMEM;
  910. goto err_power_normal;
  911. }
  912. hid_set_drvdata(hdev, (void *)dev);
  913. dev->hdev = hdev;
  914. dev->adap.owner = THIS_MODULE;
  915. dev->adap.class = I2C_CLASS_HWMON;
  916. dev->adap.algo = &smbus_algorithm;
  917. dev->adap.algo_data = dev;
  918. dev->adap.dev.parent = &hdev->dev;
  919. snprintf(dev->adap.name, sizeof(dev->adap.name),
  920. "CP2112 SMBus Bridge on hiddev%d", hdev->minor);
  921. dev->hwversion = buf[2];
  922. init_waitqueue_head(&dev->wait);
  923. hid_device_io_start(hdev);
  924. ret = i2c_add_adapter(&dev->adap);
  925. hid_device_io_stop(hdev);
  926. if (ret) {
  927. hid_err(hdev, "error registering i2c adapter\n");
  928. goto err_free_dev;
  929. }
  930. hid_dbg(hdev, "adapter registered\n");
  931. dev->gc.label = "cp2112_gpio";
  932. dev->gc.direction_input = cp2112_gpio_direction_input;
  933. dev->gc.direction_output = cp2112_gpio_direction_output;
  934. dev->gc.set = cp2112_gpio_set;
  935. dev->gc.get = cp2112_gpio_get;
  936. dev->gc.base = -1;
  937. dev->gc.ngpio = 8;
  938. dev->gc.can_sleep = 1;
  939. dev->gc.parent = &hdev->dev;
  940. ret = gpiochip_add_data(&dev->gc, dev);
  941. if (ret < 0) {
  942. hid_err(hdev, "error registering gpio chip\n");
  943. goto err_free_i2c;
  944. }
  945. ret = sysfs_create_group(&hdev->dev.kobj, &cp2112_attr_group);
  946. if (ret < 0) {
  947. hid_err(hdev, "error creating sysfs attrs\n");
  948. goto err_gpiochip_remove;
  949. }
  950. chmod_sysfs_attrs(hdev);
  951. hid_hw_power(hdev, PM_HINT_NORMAL);
  952. return ret;
  953. err_gpiochip_remove:
  954. gpiochip_remove(&dev->gc);
  955. err_free_i2c:
  956. i2c_del_adapter(&dev->adap);
  957. err_free_dev:
  958. kfree(dev);
  959. err_power_normal:
  960. hid_hw_power(hdev, PM_HINT_NORMAL);
  961. err_hid_close:
  962. hid_hw_close(hdev);
  963. err_hid_stop:
  964. hid_hw_stop(hdev);
  965. return ret;
  966. }
  967. static void cp2112_remove(struct hid_device *hdev)
  968. {
  969. struct cp2112_device *dev = hid_get_drvdata(hdev);
  970. sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group);
  971. gpiochip_remove(&dev->gc);
  972. i2c_del_adapter(&dev->adap);
  973. /* i2c_del_adapter has finished removing all i2c devices from our
  974. * adapter. Well behaved devices should no longer call our cp2112_xfer
  975. * and should have waited for any pending calls to finish. It has also
  976. * waited for device_unregister(&adap->dev) to complete. Therefore we
  977. * can safely free our struct cp2112_device.
  978. */
  979. hid_hw_close(hdev);
  980. hid_hw_stop(hdev);
  981. kfree(dev);
  982. }
  983. static int cp2112_raw_event(struct hid_device *hdev, struct hid_report *report,
  984. u8 *data, int size)
  985. {
  986. struct cp2112_device *dev = hid_get_drvdata(hdev);
  987. struct cp2112_xfer_status_report *xfer = (void *)data;
  988. switch (data[0]) {
  989. case CP2112_TRANSFER_STATUS_RESPONSE:
  990. hid_dbg(hdev, "xfer status: %02x %02x %04x %04x\n",
  991. xfer->status0, xfer->status1,
  992. be16_to_cpu(xfer->retries), be16_to_cpu(xfer->length));
  993. switch (xfer->status0) {
  994. case STATUS0_IDLE:
  995. dev->xfer_status = -EAGAIN;
  996. break;
  997. case STATUS0_BUSY:
  998. dev->xfer_status = -EBUSY;
  999. break;
  1000. case STATUS0_COMPLETE:
  1001. dev->xfer_status = be16_to_cpu(xfer->length);
  1002. break;
  1003. case STATUS0_ERROR:
  1004. switch (xfer->status1) {
  1005. case STATUS1_TIMEOUT_NACK:
  1006. case STATUS1_TIMEOUT_BUS:
  1007. dev->xfer_status = -ETIMEDOUT;
  1008. break;
  1009. default:
  1010. dev->xfer_status = -EIO;
  1011. break;
  1012. }
  1013. break;
  1014. default:
  1015. dev->xfer_status = -EINVAL;
  1016. break;
  1017. }
  1018. atomic_set(&dev->xfer_avail, 1);
  1019. break;
  1020. case CP2112_DATA_READ_RESPONSE:
  1021. hid_dbg(hdev, "read response: %02x %02x\n", data[1], data[2]);
  1022. dev->read_length = data[2];
  1023. if (dev->read_length > sizeof(dev->read_data))
  1024. dev->read_length = sizeof(dev->read_data);
  1025. memcpy(dev->read_data, &data[3], dev->read_length);
  1026. atomic_set(&dev->read_avail, 1);
  1027. break;
  1028. default:
  1029. hid_err(hdev, "unknown report\n");
  1030. return 0;
  1031. }
  1032. wake_up_interruptible(&dev->wait);
  1033. return 1;
  1034. }
  1035. static struct hid_driver cp2112_driver = {
  1036. .name = "cp2112",
  1037. .id_table = cp2112_devices,
  1038. .probe = cp2112_probe,
  1039. .remove = cp2112_remove,
  1040. .raw_event = cp2112_raw_event,
  1041. };
  1042. module_hid_driver(cp2112_driver);
  1043. MODULE_DESCRIPTION("Silicon Labs HID USB to SMBus master bridge");
  1044. MODULE_AUTHOR("David Barksdale <dbarksdale@uplogix.com>");
  1045. MODULE_LICENSE("GPL");