surface_aggregator_tabletsw.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Surface System Aggregator Module (SSAM) tablet mode switch driver.
  4. *
  5. * Copyright (C) 2022 Maximilian Luz <luzmaximilian@gmail.com>
  6. */
  7. #include <linux/unaligned.h>
  8. #include <linux/input.h>
  9. #include <linux/kernel.h>
  10. #include <linux/module.h>
  11. #include <linux/types.h>
  12. #include <linux/workqueue.h>
  13. #include <linux/surface_aggregator/controller.h>
  14. #include <linux/surface_aggregator/device.h>
  15. /* -- SSAM generic tablet switch driver framework. -------------------------- */
  16. struct ssam_tablet_sw;
  17. struct ssam_tablet_sw_state {
  18. u32 source;
  19. u32 state;
  20. };
  21. struct ssam_tablet_sw_ops {
  22. int (*get_state)(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state);
  23. const char *(*state_name)(struct ssam_tablet_sw *sw,
  24. const struct ssam_tablet_sw_state *state);
  25. bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw,
  26. const struct ssam_tablet_sw_state *state);
  27. };
  28. struct ssam_tablet_sw {
  29. struct ssam_device *sdev;
  30. struct ssam_tablet_sw_state state;
  31. struct work_struct update_work;
  32. struct input_dev *mode_switch;
  33. struct ssam_tablet_sw_ops ops;
  34. struct ssam_event_notifier notif;
  35. };
  36. struct ssam_tablet_sw_desc {
  37. struct {
  38. const char *name;
  39. const char *phys;
  40. } dev;
  41. struct {
  42. u32 (*notify)(struct ssam_event_notifier *nf, const struct ssam_event *event);
  43. int (*get_state)(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state);
  44. const char *(*state_name)(struct ssam_tablet_sw *sw,
  45. const struct ssam_tablet_sw_state *state);
  46. bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw,
  47. const struct ssam_tablet_sw_state *state);
  48. } ops;
  49. struct {
  50. struct ssam_event_registry reg;
  51. struct ssam_event_id id;
  52. enum ssam_event_mask mask;
  53. u8 flags;
  54. } event;
  55. };
  56. static ssize_t state_show(struct device *dev, struct device_attribute *attr, char *buf)
  57. {
  58. struct ssam_tablet_sw *sw = dev_get_drvdata(dev);
  59. const char *state = sw->ops.state_name(sw, &sw->state);
  60. return sysfs_emit(buf, "%s\n", state);
  61. }
  62. static DEVICE_ATTR_RO(state);
  63. static struct attribute *ssam_tablet_sw_attrs[] = {
  64. &dev_attr_state.attr,
  65. NULL,
  66. };
  67. static const struct attribute_group ssam_tablet_sw_group = {
  68. .attrs = ssam_tablet_sw_attrs,
  69. };
  70. static void ssam_tablet_sw_update_workfn(struct work_struct *work)
  71. {
  72. struct ssam_tablet_sw *sw = container_of(work, struct ssam_tablet_sw, update_work);
  73. struct ssam_tablet_sw_state state;
  74. int tablet, status;
  75. status = sw->ops.get_state(sw, &state);
  76. if (status)
  77. return;
  78. if (sw->state.source == state.source && sw->state.state == state.state)
  79. return;
  80. sw->state = state;
  81. /* Send SW_TABLET_MODE event. */
  82. tablet = sw->ops.state_is_tablet_mode(sw, &state);
  83. input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet);
  84. input_sync(sw->mode_switch);
  85. }
  86. static int __maybe_unused ssam_tablet_sw_resume(struct device *dev)
  87. {
  88. struct ssam_tablet_sw *sw = dev_get_drvdata(dev);
  89. schedule_work(&sw->update_work);
  90. return 0;
  91. }
  92. static SIMPLE_DEV_PM_OPS(ssam_tablet_sw_pm_ops, NULL, ssam_tablet_sw_resume);
  93. static int ssam_tablet_sw_probe(struct ssam_device *sdev)
  94. {
  95. const struct ssam_tablet_sw_desc *desc;
  96. struct ssam_tablet_sw *sw;
  97. int tablet, status;
  98. desc = ssam_device_get_match_data(sdev);
  99. if (!desc) {
  100. WARN(1, "no driver match data specified");
  101. return -EINVAL;
  102. }
  103. sw = devm_kzalloc(&sdev->dev, sizeof(*sw), GFP_KERNEL);
  104. if (!sw)
  105. return -ENOMEM;
  106. sw->sdev = sdev;
  107. sw->ops.get_state = desc->ops.get_state;
  108. sw->ops.state_name = desc->ops.state_name;
  109. sw->ops.state_is_tablet_mode = desc->ops.state_is_tablet_mode;
  110. INIT_WORK(&sw->update_work, ssam_tablet_sw_update_workfn);
  111. ssam_device_set_drvdata(sdev, sw);
  112. /* Get initial state. */
  113. status = sw->ops.get_state(sw, &sw->state);
  114. if (status)
  115. return status;
  116. /* Set up tablet mode switch. */
  117. sw->mode_switch = devm_input_allocate_device(&sdev->dev);
  118. if (!sw->mode_switch)
  119. return -ENOMEM;
  120. sw->mode_switch->name = desc->dev.name;
  121. sw->mode_switch->phys = desc->dev.phys;
  122. sw->mode_switch->id.bustype = BUS_HOST;
  123. sw->mode_switch->dev.parent = &sdev->dev;
  124. tablet = sw->ops.state_is_tablet_mode(sw, &sw->state);
  125. input_set_capability(sw->mode_switch, EV_SW, SW_TABLET_MODE);
  126. input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet);
  127. status = input_register_device(sw->mode_switch);
  128. if (status)
  129. return status;
  130. /* Set up notifier. */
  131. sw->notif.base.priority = 0;
  132. sw->notif.base.fn = desc->ops.notify;
  133. sw->notif.event.reg = desc->event.reg;
  134. sw->notif.event.id = desc->event.id;
  135. sw->notif.event.mask = desc->event.mask;
  136. sw->notif.event.flags = SSAM_EVENT_SEQUENCED;
  137. status = ssam_device_notifier_register(sdev, &sw->notif);
  138. if (status)
  139. return status;
  140. status = sysfs_create_group(&sdev->dev.kobj, &ssam_tablet_sw_group);
  141. if (status)
  142. goto err;
  143. /* We might have missed events during setup, so check again. */
  144. schedule_work(&sw->update_work);
  145. return 0;
  146. err:
  147. ssam_device_notifier_unregister(sdev, &sw->notif);
  148. cancel_work_sync(&sw->update_work);
  149. return status;
  150. }
  151. static void ssam_tablet_sw_remove(struct ssam_device *sdev)
  152. {
  153. struct ssam_tablet_sw *sw = ssam_device_get_drvdata(sdev);
  154. sysfs_remove_group(&sdev->dev.kobj, &ssam_tablet_sw_group);
  155. ssam_device_notifier_unregister(sdev, &sw->notif);
  156. cancel_work_sync(&sw->update_work);
  157. }
  158. /* -- SSAM KIP tablet switch implementation. -------------------------------- */
  159. #define SSAM_EVENT_KIP_CID_COVER_STATE_CHANGED 0x1d
  160. enum ssam_kip_cover_state {
  161. SSAM_KIP_COVER_STATE_DISCONNECTED = 0x01,
  162. SSAM_KIP_COVER_STATE_CLOSED = 0x02,
  163. SSAM_KIP_COVER_STATE_LAPTOP = 0x03,
  164. SSAM_KIP_COVER_STATE_FOLDED_CANVAS = 0x04,
  165. SSAM_KIP_COVER_STATE_FOLDED_BACK = 0x05,
  166. SSAM_KIP_COVER_STATE_BOOK = 0x06,
  167. };
  168. static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw,
  169. const struct ssam_tablet_sw_state *state)
  170. {
  171. switch (state->state) {
  172. case SSAM_KIP_COVER_STATE_DISCONNECTED:
  173. return "disconnected";
  174. case SSAM_KIP_COVER_STATE_CLOSED:
  175. return "closed";
  176. case SSAM_KIP_COVER_STATE_LAPTOP:
  177. return "laptop";
  178. case SSAM_KIP_COVER_STATE_FOLDED_CANVAS:
  179. return "folded-canvas";
  180. case SSAM_KIP_COVER_STATE_FOLDED_BACK:
  181. return "folded-back";
  182. case SSAM_KIP_COVER_STATE_BOOK:
  183. return "book";
  184. default:
  185. dev_warn(&sw->sdev->dev, "unknown KIP cover state: %u\n", state->state);
  186. return "<unknown>";
  187. }
  188. }
  189. static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw,
  190. const struct ssam_tablet_sw_state *state)
  191. {
  192. switch (state->state) {
  193. case SSAM_KIP_COVER_STATE_DISCONNECTED:
  194. case SSAM_KIP_COVER_STATE_FOLDED_CANVAS:
  195. case SSAM_KIP_COVER_STATE_FOLDED_BACK:
  196. case SSAM_KIP_COVER_STATE_BOOK:
  197. return true;
  198. case SSAM_KIP_COVER_STATE_CLOSED:
  199. case SSAM_KIP_COVER_STATE_LAPTOP:
  200. return false;
  201. default:
  202. dev_warn(&sw->sdev->dev, "unknown KIP cover state: %d\n", state->state);
  203. return true;
  204. }
  205. }
  206. SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_get_cover_state, u8, {
  207. .target_category = SSAM_SSH_TC_KIP,
  208. .target_id = SSAM_SSH_TID_SAM,
  209. .command_id = 0x1d,
  210. .instance_id = 0x00,
  211. });
  212. static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state)
  213. {
  214. int status;
  215. u8 raw;
  216. status = ssam_retry(__ssam_kip_get_cover_state, sw->sdev->ctrl, &raw);
  217. if (status < 0) {
  218. dev_err(&sw->sdev->dev, "failed to query KIP lid state: %d\n", status);
  219. return status;
  220. }
  221. state->source = 0; /* Unused for KIP switch. */
  222. state->state = raw;
  223. return 0;
  224. }
  225. static u32 ssam_kip_sw_notif(struct ssam_event_notifier *nf, const struct ssam_event *event)
  226. {
  227. struct ssam_tablet_sw *sw = container_of(nf, struct ssam_tablet_sw, notif);
  228. if (event->command_id != SSAM_EVENT_KIP_CID_COVER_STATE_CHANGED)
  229. return 0; /* Return "unhandled". */
  230. if (event->length < 1)
  231. dev_warn(&sw->sdev->dev, "unexpected payload size: %u\n", event->length);
  232. schedule_work(&sw->update_work);
  233. return SSAM_NOTIF_HANDLED;
  234. }
  235. static const struct ssam_tablet_sw_desc ssam_kip_sw_desc = {
  236. .dev = {
  237. .name = "Microsoft Surface KIP Tablet Mode Switch",
  238. .phys = "ssam/01:0e:01:00:01/input0",
  239. },
  240. .ops = {
  241. .notify = ssam_kip_sw_notif,
  242. .get_state = ssam_kip_get_cover_state,
  243. .state_name = ssam_kip_cover_state_name,
  244. .state_is_tablet_mode = ssam_kip_cover_state_is_tablet_mode,
  245. },
  246. .event = {
  247. .reg = SSAM_EVENT_REGISTRY_SAM,
  248. .id = {
  249. .target_category = SSAM_SSH_TC_KIP,
  250. .instance = 0,
  251. },
  252. .mask = SSAM_EVENT_MASK_TARGET,
  253. },
  254. };
  255. /* -- SSAM POS tablet switch implementation. -------------------------------- */
  256. static bool tablet_mode_in_slate_state = true;
  257. module_param(tablet_mode_in_slate_state, bool, 0644);
  258. MODULE_PARM_DESC(tablet_mode_in_slate_state, "Enable tablet mode in slate device posture, default is 'true'");
  259. #define SSAM_EVENT_POS_CID_POSTURE_CHANGED 0x03
  260. #define SSAM_POS_MAX_SOURCES 4
  261. enum ssam_pos_source_id {
  262. SSAM_POS_SOURCE_COVER = 0x00,
  263. SSAM_POS_SOURCE_SLS = 0x03,
  264. };
  265. enum ssam_pos_state_cover {
  266. SSAM_POS_COVER_DISCONNECTED = 0x01,
  267. SSAM_POS_COVER_CLOSED = 0x02,
  268. SSAM_POS_COVER_LAPTOP = 0x03,
  269. SSAM_POS_COVER_FOLDED_CANVAS = 0x04,
  270. SSAM_POS_COVER_FOLDED_BACK = 0x05,
  271. SSAM_POS_COVER_BOOK = 0x06,
  272. };
  273. enum ssam_pos_state_sls {
  274. SSAM_POS_SLS_LID_CLOSED = 0x00,
  275. SSAM_POS_SLS_LAPTOP = 0x01,
  276. SSAM_POS_SLS_SLATE = 0x02,
  277. SSAM_POS_SLS_TABLET = 0x03,
  278. };
  279. struct ssam_sources_list {
  280. __le32 count;
  281. __le32 id[SSAM_POS_MAX_SOURCES];
  282. } __packed;
  283. static const char *ssam_pos_state_name_cover(struct ssam_tablet_sw *sw, u32 state)
  284. {
  285. switch (state) {
  286. case SSAM_POS_COVER_DISCONNECTED:
  287. return "disconnected";
  288. case SSAM_POS_COVER_CLOSED:
  289. return "closed";
  290. case SSAM_POS_COVER_LAPTOP:
  291. return "laptop";
  292. case SSAM_POS_COVER_FOLDED_CANVAS:
  293. return "folded-canvas";
  294. case SSAM_POS_COVER_FOLDED_BACK:
  295. return "folded-back";
  296. case SSAM_POS_COVER_BOOK:
  297. return "book";
  298. default:
  299. dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state);
  300. return "<unknown>";
  301. }
  302. }
  303. static const char *ssam_pos_state_name_sls(struct ssam_tablet_sw *sw, u32 state)
  304. {
  305. switch (state) {
  306. case SSAM_POS_SLS_LID_CLOSED:
  307. return "closed";
  308. case SSAM_POS_SLS_LAPTOP:
  309. return "laptop";
  310. case SSAM_POS_SLS_SLATE:
  311. return "slate";
  312. case SSAM_POS_SLS_TABLET:
  313. return "tablet";
  314. default:
  315. dev_warn(&sw->sdev->dev, "unknown device posture for SLS: %u\n", state);
  316. return "<unknown>";
  317. }
  318. }
  319. static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw,
  320. const struct ssam_tablet_sw_state *state)
  321. {
  322. switch (state->source) {
  323. case SSAM_POS_SOURCE_COVER:
  324. return ssam_pos_state_name_cover(sw, state->state);
  325. case SSAM_POS_SOURCE_SLS:
  326. return ssam_pos_state_name_sls(sw, state->state);
  327. default:
  328. dev_warn(&sw->sdev->dev, "unknown device posture source: %u\n", state->source);
  329. return "<unknown>";
  330. }
  331. }
  332. static bool ssam_pos_state_is_tablet_mode_cover(struct ssam_tablet_sw *sw, u32 state)
  333. {
  334. switch (state) {
  335. case SSAM_POS_COVER_DISCONNECTED:
  336. case SSAM_POS_COVER_FOLDED_CANVAS:
  337. case SSAM_POS_COVER_FOLDED_BACK:
  338. case SSAM_POS_COVER_BOOK:
  339. return true;
  340. case SSAM_POS_COVER_CLOSED:
  341. case SSAM_POS_COVER_LAPTOP:
  342. return false;
  343. default:
  344. dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state);
  345. return true;
  346. }
  347. }
  348. static bool ssam_pos_state_is_tablet_mode_sls(struct ssam_tablet_sw *sw, u32 state)
  349. {
  350. switch (state) {
  351. case SSAM_POS_SLS_LAPTOP:
  352. case SSAM_POS_SLS_LID_CLOSED:
  353. return false;
  354. case SSAM_POS_SLS_SLATE:
  355. return tablet_mode_in_slate_state;
  356. case SSAM_POS_SLS_TABLET:
  357. return true;
  358. default:
  359. dev_warn(&sw->sdev->dev, "unknown device posture for SLS: %u\n", state);
  360. return true;
  361. }
  362. }
  363. static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw,
  364. const struct ssam_tablet_sw_state *state)
  365. {
  366. switch (state->source) {
  367. case SSAM_POS_SOURCE_COVER:
  368. return ssam_pos_state_is_tablet_mode_cover(sw, state->state);
  369. case SSAM_POS_SOURCE_SLS:
  370. return ssam_pos_state_is_tablet_mode_sls(sw, state->state);
  371. default:
  372. dev_warn(&sw->sdev->dev, "unknown device posture source: %u\n", state->source);
  373. return true;
  374. }
  375. }
  376. static int ssam_pos_get_sources_list(struct ssam_tablet_sw *sw, struct ssam_sources_list *sources)
  377. {
  378. struct ssam_request rqst;
  379. struct ssam_response rsp;
  380. int status;
  381. rqst.target_category = SSAM_SSH_TC_POS;
  382. rqst.target_id = SSAM_SSH_TID_SAM;
  383. rqst.command_id = 0x01;
  384. rqst.instance_id = 0x00;
  385. rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
  386. rqst.length = 0;
  387. rqst.payload = NULL;
  388. rsp.capacity = sizeof(*sources);
  389. rsp.length = 0;
  390. rsp.pointer = (u8 *)sources;
  391. status = ssam_retry(ssam_request_do_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0);
  392. if (status)
  393. return status;
  394. /* We need at least the 'sources->count' field. */
  395. if (rsp.length < sizeof(__le32)) {
  396. dev_err(&sw->sdev->dev, "received source list response is too small\n");
  397. return -EPROTO;
  398. }
  399. /* Make sure 'sources->count' matches with the response length. */
  400. if (get_unaligned_le32(&sources->count) * sizeof(__le32) + sizeof(__le32) != rsp.length) {
  401. dev_err(&sw->sdev->dev, "mismatch between number of sources and response size\n");
  402. return -EPROTO;
  403. }
  404. return 0;
  405. }
  406. static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
  407. {
  408. struct ssam_sources_list sources = {};
  409. int status;
  410. status = ssam_pos_get_sources_list(sw, &sources);
  411. if (status)
  412. return status;
  413. if (get_unaligned_le32(&sources.count) == 0) {
  414. dev_err(&sw->sdev->dev, "no posture sources found\n");
  415. return -ENODEV;
  416. }
  417. /*
  418. * We currently don't know what to do with more than one posture
  419. * source. At the moment, only one source seems to be used/provided.
  420. * The WARN_ON() here should hopefully let us know quickly once there
  421. * is a device that provides multiple sources, at which point we can
  422. * then try to figure out how to handle them.
  423. */
  424. WARN_ON(get_unaligned_le32(&sources.count) > 1);
  425. *source_id = get_unaligned_le32(&sources.id[0]);
  426. return 0;
  427. }
  428. SSAM_DEFINE_SYNC_REQUEST_WR(__ssam_pos_get_posture_for_source, __le32, __le32, {
  429. .target_category = SSAM_SSH_TC_POS,
  430. .target_id = SSAM_SSH_TID_SAM,
  431. .command_id = 0x02,
  432. .instance_id = 0x00,
  433. });
  434. static int ssam_pos_get_posture_for_source(struct ssam_tablet_sw *sw, u32 source_id, u32 *posture)
  435. {
  436. __le32 source_le = cpu_to_le32(source_id);
  437. __le32 rspval_le = 0;
  438. int status;
  439. status = ssam_retry(__ssam_pos_get_posture_for_source, sw->sdev->ctrl,
  440. &source_le, &rspval_le);
  441. if (status)
  442. return status;
  443. *posture = le32_to_cpu(rspval_le);
  444. return 0;
  445. }
  446. static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state)
  447. {
  448. u32 source_id;
  449. u32 source_state;
  450. int status;
  451. status = ssam_pos_get_source(sw, &source_id);
  452. if (status) {
  453. dev_err(&sw->sdev->dev, "failed to get posture source ID: %d\n", status);
  454. return status;
  455. }
  456. status = ssam_pos_get_posture_for_source(sw, source_id, &source_state);
  457. if (status) {
  458. dev_err(&sw->sdev->dev, "failed to get posture value for source %u: %d\n",
  459. source_id, status);
  460. return status;
  461. }
  462. state->source = source_id;
  463. state->state = source_state;
  464. return 0;
  465. }
  466. static u32 ssam_pos_sw_notif(struct ssam_event_notifier *nf, const struct ssam_event *event)
  467. {
  468. struct ssam_tablet_sw *sw = container_of(nf, struct ssam_tablet_sw, notif);
  469. if (event->command_id != SSAM_EVENT_POS_CID_POSTURE_CHANGED)
  470. return 0; /* Return "unhandled". */
  471. if (event->length != sizeof(__le32) * 3)
  472. dev_warn(&sw->sdev->dev, "unexpected payload size: %u\n", event->length);
  473. schedule_work(&sw->update_work);
  474. return SSAM_NOTIF_HANDLED;
  475. }
  476. static const struct ssam_tablet_sw_desc ssam_pos_sw_desc = {
  477. .dev = {
  478. .name = "Microsoft Surface POS Tablet Mode Switch",
  479. .phys = "ssam/01:26:01:00:01/input0",
  480. },
  481. .ops = {
  482. .notify = ssam_pos_sw_notif,
  483. .get_state = ssam_pos_get_posture,
  484. .state_name = ssam_pos_state_name,
  485. .state_is_tablet_mode = ssam_pos_state_is_tablet_mode,
  486. },
  487. .event = {
  488. .reg = SSAM_EVENT_REGISTRY_SAM,
  489. .id = {
  490. .target_category = SSAM_SSH_TC_POS,
  491. .instance = 0,
  492. },
  493. .mask = SSAM_EVENT_MASK_TARGET,
  494. },
  495. };
  496. /* -- Driver registration. -------------------------------------------------- */
  497. static const struct ssam_device_id ssam_tablet_sw_match[] = {
  498. { SSAM_SDEV(KIP, SAM, 0x00, 0x01), (unsigned long)&ssam_kip_sw_desc },
  499. { SSAM_SDEV(POS, SAM, 0x00, 0x01), (unsigned long)&ssam_pos_sw_desc },
  500. { },
  501. };
  502. MODULE_DEVICE_TABLE(ssam, ssam_tablet_sw_match);
  503. static struct ssam_device_driver ssam_tablet_sw_driver = {
  504. .probe = ssam_tablet_sw_probe,
  505. .remove = ssam_tablet_sw_remove,
  506. .match_table = ssam_tablet_sw_match,
  507. .driver = {
  508. .name = "surface_aggregator_tablet_mode_switch",
  509. .probe_type = PROBE_PREFER_ASYNCHRONOUS,
  510. .pm = &ssam_tablet_sw_pm_ops,
  511. },
  512. };
  513. module_ssam_device_driver(ssam_tablet_sw_driver);
  514. MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>");
  515. MODULE_DESCRIPTION("Tablet mode switch driver for Surface devices using the Surface Aggregator Module");
  516. MODULE_LICENSE("GPL");