1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for Intel PMC USB mux control
5 * Copyright (C) 2020 Intel Corporation
6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
9 #include <linux/acpi.h>
10 #include <linux/module.h>
11 #include <linux/platform_device.h>
12 #include <linux/property.h>
13 #include <linux/usb/pd.h>
14 #include <linux/usb/role.h>
15 #include <linux/usb/typec_mux.h>
16 #include <linux/usb/typec_dp.h>
17 #include <linux/usb/typec_tbt.h>
18 #include <linux/debugfs.h>
19 #include <linux/usb.h>
21 #include <asm/intel_scu_ipc.h>
23 #define PMC_USBC_CMD 0xa7
25 /* Response status bits */
26 #define PMC_USB_RESP_STATUS_FAILURE BIT(0)
27 #define PMC_USB_RESP_STATUS_FATAL BIT(1)
29 /* "Usage" OOB Message field values */
38 #define PMC_USB_MSG_USB2_PORT_SHIFT 0
39 #define PMC_USB_MSG_USB3_PORT_SHIFT 4
40 #define PMC_USB_MSG_UFP_SHIFT 4
41 #define PMC_USB_MSG_ORI_HSL_SHIFT 5
42 #define PMC_USB_MSG_ORI_AUX_SHIFT 6
44 /* Alt Mode Request */
53 #define PMC_USB_MODE_TYPE_SHIFT 4
56 PMC_USB_MODE_TYPE_USB,
58 PMC_USB_MODE_TYPE_TBT,
61 /* Common Mode Data bits */
62 #define PMC_USB_ALTMODE_ACTIVE_CABLE BIT(2)
64 #define PMC_USB_ALTMODE_ORI_SHIFT 1
65 #define PMC_USB_ALTMODE_UFP_SHIFT 3
67 /* DP specific Mode Data bits */
68 #define PMC_USB_ALTMODE_DP_MODE_SHIFT 8
70 /* TBT specific Mode Data bits */
71 #define PMC_USB_ALTMODE_TBT_TYPE BIT(17)
72 #define PMC_USB_ALTMODE_CABLE_TYPE BIT(18)
73 #define PMC_USB_ALTMODE_ACTIVE_LINK BIT(20)
74 #define PMC_USB_ALTMODE_FORCE_LSR BIT(23)
75 #define PMC_USB_ALTMODE_CABLE_SPD(_s_) (((_s_) & GENMASK(2, 0)) << 25)
76 #define PMC_USB_ALTMODE_CABLE_USB31 1
77 #define PMC_USB_ALTMODE_CABLE_10GPS 2
78 #define PMC_USB_ALTMODE_CABLE_20GPS 3
79 #define PMC_USB_ALTMODE_TBT_GEN(_g_) (((_g_) & GENMASK(1, 0)) << 28)
81 /* Display HPD Request bits */
82 #define PMC_USB_DP_HPD_LVL BIT(4)
83 #define PMC_USB_DP_HPD_IRQ BIT(5)
86 * Input Output Manager (IOM) PORT STATUS
88 #define IOM_PORT_STATUS_ACTIVITY_TYPE_MASK GENMASK(9, 6)
89 #define IOM_PORT_STATUS_ACTIVITY_TYPE_SHIFT 6
90 #define IOM_PORT_STATUS_ACTIVITY_TYPE_USB 0x03
91 /* activity type: Safe Mode */
92 #define IOM_PORT_STATUS_ACTIVITY_TYPE_SAFE_MODE 0x04
93 /* activity type: Display Port */
94 #define IOM_PORT_STATUS_ACTIVITY_TYPE_DP 0x05
95 /* activity type: Display Port Multi Function Device */
96 #define IOM_PORT_STATUS_ACTIVITY_TYPE_DP_MFD 0x06
97 /* activity type: Thunderbolt */
98 #define IOM_PORT_STATUS_ACTIVITY_TYPE_TBT 0x07
99 #define IOM_PORT_STATUS_ACTIVITY_TYPE_ALT_MODE_USB 0x0c
100 #define IOM_PORT_STATUS_ACTIVITY_TYPE_ALT_MODE_TBT_USB 0x0d
101 /* Upstream Facing Port Information */
102 #define IOM_PORT_STATUS_UFP BIT(10)
103 /* Display Port Hot Plug Detect status */
104 #define IOM_PORT_STATUS_DHPD_HPD_STATUS_MASK GENMASK(13, 12)
105 #define IOM_PORT_STATUS_DHPD_HPD_STATUS_SHIFT 12
106 #define IOM_PORT_STATUS_DHPD_HPD_STATUS_ASSERT 0x01
107 #define IOM_PORT_STATUS_DHPD_HPD_SOURCE_TBT BIT(14)
108 #define IOM_PORT_STATUS_CONNECTED BIT(31)
110 #define IOM_PORT_ACTIVITY_IS(_status_, _type_) \
111 ((((_status_) & IOM_PORT_STATUS_ACTIVITY_TYPE_MASK) >> \
112 IOM_PORT_STATUS_ACTIVITY_TYPE_SHIFT) == \
113 (IOM_PORT_STATUS_ACTIVITY_TYPE_##_type_))
115 #define IOM_PORT_HPD_ASSERTED(_status_) \
116 ((((_status_) & IOM_PORT_STATUS_DHPD_HPD_STATUS_MASK) >> \
117 IOM_PORT_STATUS_DHPD_HPD_STATUS_SHIFT) & \
118 IOM_PORT_STATUS_DHPD_HPD_STATUS_ASSERT)
122 struct pmc_usb_port {
126 struct typec_mux_dev *typec_mux;
127 struct typec_switch_dev *typec_sw;
128 struct usb_role_switch *usb_sw;
130 enum typec_orientation orientation;
136 enum typec_orientation sbu_orientation;
137 enum typec_orientation hsl_orientation;
143 struct intel_scu_ipc_dev *ipc;
144 struct pmc_usb_port *port;
145 struct acpi_device *iom_adev;
146 void __iomem *iom_base;
147 u32 iom_port_status_offset;
149 struct dentry *dentry;
152 static struct dentry *pmc_mux_debugfs_root;
154 static void update_port_status(struct pmc_usb_port *port)
158 /* SoC expects the USB Type-C port numbers to start with 0 */
159 port_num = port->usb3_port - 1;
161 port->iom_status = readl(port->pmc->iom_base +
162 port->pmc->iom_port_status_offset +
163 port_num * sizeof(u32));
166 static int sbu_orientation(struct pmc_usb_port *port)
168 if (port->sbu_orientation)
169 return port->sbu_orientation - 1;
171 return port->orientation - 1;
174 static int hsl_orientation(struct pmc_usb_port *port)
176 if (port->hsl_orientation)
177 return port->hsl_orientation - 1;
179 return port->orientation - 1;
182 static int pmc_usb_send_command(struct intel_scu_ipc_dev *ipc, u8 *msg, u32 len)
189 * Error bit will always be 0 with the USBC command.
190 * Status can be checked from the response message if the
191 * function intel_scu_ipc_dev_command succeeds.
193 ret = intel_scu_ipc_dev_command(ipc, PMC_USBC_CMD, 0, msg,
194 len, response, sizeof(response));
199 status_res = (msg[0] & 0xf) < PMC_USB_SAFE_MODE ?
200 response[2] : response[1];
202 if (status_res & PMC_USB_RESP_STATUS_FAILURE) {
203 if (status_res & PMC_USB_RESP_STATUS_FATAL)
212 static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)
218 * If PMC is busy then retry the command once again
220 while (retry_count--) {
221 ret = pmc_usb_send_command(port->pmc->ipc, msg, len);
230 pmc_usb_mux_dp_hpd(struct pmc_usb_port *port, struct typec_displayport_data *dp)
235 msg[0] = PMC_USB_DP_HPD;
236 msg[0] |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT;
238 /* Configure HPD first if HPD,IRQ comes together */
239 if (!IOM_PORT_HPD_ASSERTED(port->iom_status) &&
240 dp->status & DP_STATUS_IRQ_HPD &&
241 dp->status & DP_STATUS_HPD_STATE) {
242 msg[1] = PMC_USB_DP_HPD_LVL;
243 ret = pmc_usb_command(port, msg, sizeof(msg));
248 if (dp->status & DP_STATUS_IRQ_HPD)
249 msg[1] = PMC_USB_DP_HPD_IRQ;
251 if (dp->status & DP_STATUS_HPD_STATE)
252 msg[1] |= PMC_USB_DP_HPD_LVL;
254 return pmc_usb_command(port, msg, sizeof(msg));
258 pmc_usb_mux_dp(struct pmc_usb_port *port, struct typec_mux_state *state)
260 struct typec_displayport_data *data = state->data;
261 struct altmode_req req = { };
264 if (IOM_PORT_ACTIVITY_IS(port->iom_status, DP) ||
265 IOM_PORT_ACTIVITY_IS(port->iom_status, DP_MFD)) {
266 if (IOM_PORT_HPD_ASSERTED(port->iom_status) &&
267 (!(data->status & DP_STATUS_IRQ_HPD) &&
268 data->status & DP_STATUS_HPD_STATE))
271 return pmc_usb_mux_dp_hpd(port, state->data);
274 req.usage = PMC_USB_ALT_MODE;
275 req.usage |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT;
276 req.mode_type = PMC_USB_MODE_TYPE_DP << PMC_USB_MODE_TYPE_SHIFT;
278 req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
279 req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
281 req.mode_data |= (state->mode - TYPEC_STATE_MODAL) <<
282 PMC_USB_ALTMODE_DP_MODE_SHIFT;
284 ret = pmc_usb_command(port, (void *)&req, sizeof(req));
288 if (data->status & (DP_STATUS_IRQ_HPD | DP_STATUS_HPD_STATE))
289 return pmc_usb_mux_dp_hpd(port, state->data);
295 pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
297 struct typec_thunderbolt_data *data = state->data;
298 u8 cable_rounded = TBT_CABLE_ROUNDED_SUPPORT(data->cable_mode);
299 u8 cable_speed = TBT_CABLE_SPEED(data->cable_mode);
300 struct altmode_req req = { };
302 if (IOM_PORT_ACTIVITY_IS(port->iom_status, TBT) ||
303 IOM_PORT_ACTIVITY_IS(port->iom_status, ALT_MODE_TBT_USB))
306 req.usage = PMC_USB_ALT_MODE;
307 req.usage |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT;
308 req.mode_type = PMC_USB_MODE_TYPE_TBT << PMC_USB_MODE_TYPE_SHIFT;
310 req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
311 req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
313 if (TBT_ADAPTER(data->device_mode) == TBT_ADAPTER_TBT3)
314 req.mode_data |= PMC_USB_ALTMODE_TBT_TYPE;
316 if (data->cable_mode & TBT_CABLE_OPTICAL)
317 req.mode_data |= PMC_USB_ALTMODE_CABLE_TYPE;
319 if (data->cable_mode & TBT_CABLE_LINK_TRAINING)
320 req.mode_data |= PMC_USB_ALTMODE_ACTIVE_LINK;
322 if (data->enter_vdo & TBT_ENTER_MODE_ACTIVE_CABLE)
323 req.mode_data |= PMC_USB_ALTMODE_ACTIVE_CABLE;
325 req.mode_data |= PMC_USB_ALTMODE_CABLE_SPD(cable_speed);
327 req.mode_data |= PMC_USB_ALTMODE_TBT_GEN(cable_rounded);
329 return pmc_usb_command(port, (void *)&req, sizeof(req));
333 pmc_usb_mux_usb4(struct pmc_usb_port *port, struct typec_mux_state *state)
335 struct enter_usb_data *data = state->data;
336 struct altmode_req req = { };
339 if (IOM_PORT_ACTIVITY_IS(port->iom_status, TBT) ||
340 IOM_PORT_ACTIVITY_IS(port->iom_status, ALT_MODE_TBT_USB))
343 req.usage = PMC_USB_ALT_MODE;
344 req.usage |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT;
345 req.mode_type = PMC_USB_MODE_TYPE_TBT << PMC_USB_MODE_TYPE_SHIFT;
348 req.mode_data = PMC_USB_ALTMODE_FORCE_LSR;
350 if (data->active_link_training)
351 req.mode_data |= PMC_USB_ALTMODE_ACTIVE_LINK;
353 req.mode_data |= (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
354 req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
356 switch ((data->eudo & EUDO_CABLE_TYPE_MASK) >> EUDO_CABLE_TYPE_SHIFT) {
357 case EUDO_CABLE_TYPE_PASSIVE:
359 case EUDO_CABLE_TYPE_OPTICAL:
360 req.mode_data |= PMC_USB_ALTMODE_CABLE_TYPE;
363 req.mode_data |= PMC_USB_ALTMODE_ACTIVE_CABLE;
365 /* Configure data rate to rounded in the case of Active TBT3
368 req.mode_data |= PMC_USB_ALTMODE_TBT_GEN(1);
372 cable_speed = (data->eudo & EUDO_CABLE_SPEED_MASK) >> EUDO_CABLE_SPEED_SHIFT;
373 req.mode_data |= PMC_USB_ALTMODE_CABLE_SPD(cable_speed);
375 return pmc_usb_command(port, (void *)&req, sizeof(req));
378 static int pmc_usb_mux_safe_state(struct pmc_usb_port *port,
379 struct typec_mux_state *state)
383 if (IOM_PORT_ACTIVITY_IS(port->iom_status, SAFE_MODE))
386 if ((IOM_PORT_ACTIVITY_IS(port->iom_status, DP) ||
387 IOM_PORT_ACTIVITY_IS(port->iom_status, DP_MFD)) &&
388 state->alt && state->alt->svid == USB_TYPEC_DP_SID)
391 if ((IOM_PORT_ACTIVITY_IS(port->iom_status, TBT) ||
392 IOM_PORT_ACTIVITY_IS(port->iom_status, ALT_MODE_TBT_USB)) &&
393 state->alt && state->alt->svid == USB_TYPEC_TBT_SID)
396 msg = PMC_USB_SAFE_MODE;
397 msg |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT;
399 return pmc_usb_command(port, &msg, sizeof(msg));
402 static int pmc_usb_disconnect(struct pmc_usb_port *port)
404 struct typec_displayport_data data = { };
407 if (!(port->iom_status & IOM_PORT_STATUS_CONNECTED))
410 /* Clear DisplayPort HPD if it's still asserted. */
411 if (IOM_PORT_HPD_ASSERTED(port->iom_status))
412 pmc_usb_mux_dp_hpd(port, &data);
414 msg[0] = PMC_USB_DISCONNECT;
415 msg[0] |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT;
417 msg[1] = port->usb2_port << PMC_USB_MSG_USB2_PORT_SHIFT;
419 return pmc_usb_command(port, msg, sizeof(msg));
422 static int pmc_usb_connect(struct pmc_usb_port *port, enum usb_role role)
424 u8 ufp = role == USB_ROLE_DEVICE ? 1 : 0;
428 if (port->orientation == TYPEC_ORIENTATION_NONE)
431 if (port->iom_status & IOM_PORT_STATUS_CONNECTED) {
432 if (port->role == role || port->role == USB_ROLE_NONE)
436 ret = pmc_usb_disconnect(port);
441 msg[0] = PMC_USB_CONNECT;
442 msg[0] |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT;
444 msg[1] = port->usb2_port << PMC_USB_MSG_USB2_PORT_SHIFT;
445 msg[1] |= ufp << PMC_USB_MSG_UFP_SHIFT;
446 msg[1] |= hsl_orientation(port) << PMC_USB_MSG_ORI_HSL_SHIFT;
447 msg[1] |= sbu_orientation(port) << PMC_USB_MSG_ORI_AUX_SHIFT;
449 return pmc_usb_command(port, msg, sizeof(msg));
453 pmc_usb_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state)
455 struct pmc_usb_port *port = typec_mux_get_drvdata(mux);
457 update_port_status(port);
459 if (port->orientation == TYPEC_ORIENTATION_NONE || port->role == USB_ROLE_NONE)
462 if (state->mode == TYPEC_STATE_SAFE)
463 return pmc_usb_mux_safe_state(port, state);
464 if (state->mode == TYPEC_STATE_USB)
465 return pmc_usb_connect(port, port->role);
468 switch (state->alt->svid) {
469 case USB_TYPEC_TBT_SID:
470 return pmc_usb_mux_tbt(port, state);
471 case USB_TYPEC_DP_SID:
472 return pmc_usb_mux_dp(port, state);
475 switch (state->mode) {
476 case TYPEC_MODE_USB2:
477 /* REVISIT: Try with usb3_port set to 0? */
479 case TYPEC_MODE_USB3:
480 return pmc_usb_connect(port, port->role);
481 case TYPEC_MODE_USB4:
482 return pmc_usb_mux_usb4(port, state);
489 static int pmc_usb_set_orientation(struct typec_switch_dev *sw,
490 enum typec_orientation orientation)
492 struct pmc_usb_port *port = typec_switch_get_drvdata(sw);
494 update_port_status(port);
496 port->orientation = orientation;
501 static int pmc_usb_set_role(struct usb_role_switch *sw, enum usb_role role)
503 struct pmc_usb_port *port = usb_role_switch_get_drvdata(sw);
506 update_port_status(port);
508 if (role == USB_ROLE_NONE)
509 ret = pmc_usb_disconnect(port);
511 ret = pmc_usb_connect(port, role);
518 static int pmc_usb_register_port(struct pmc_usb *pmc, int index,
519 struct fwnode_handle *fwnode)
521 struct pmc_usb_port *port = &pmc->port[index];
522 struct usb_role_switch_desc desc = { };
523 struct typec_switch_desc sw_desc = { };
524 struct typec_mux_desc mux_desc = { };
528 ret = fwnode_property_read_u8(fwnode, "usb2-port-number", &port->usb2_port);
532 ret = fwnode_property_read_u8(fwnode, "usb3-port-number", &port->usb3_port);
536 ret = fwnode_property_read_string(fwnode, "sbu-orientation", &str);
538 port->sbu_orientation = typec_find_orientation(str);
540 ret = fwnode_property_read_string(fwnode, "hsl-orientation", &str);
542 port->hsl_orientation = typec_find_orientation(str);
547 sw_desc.fwnode = fwnode;
548 sw_desc.drvdata = port;
549 sw_desc.name = fwnode_get_name(fwnode);
550 sw_desc.set = pmc_usb_set_orientation;
552 port->typec_sw = typec_switch_register(pmc->dev, &sw_desc);
553 if (IS_ERR(port->typec_sw))
554 return PTR_ERR(port->typec_sw);
556 mux_desc.fwnode = fwnode;
557 mux_desc.drvdata = port;
558 mux_desc.name = fwnode_get_name(fwnode);
559 mux_desc.set = pmc_usb_mux_set;
561 port->typec_mux = typec_mux_register(pmc->dev, &mux_desc);
562 if (IS_ERR(port->typec_mux)) {
563 ret = PTR_ERR(port->typec_mux);
564 goto err_unregister_switch;
567 desc.fwnode = fwnode;
568 desc.driver_data = port;
569 desc.name = fwnode_get_name(fwnode);
570 desc.set = pmc_usb_set_role;
572 port->usb_sw = usb_role_switch_register(pmc->dev, &desc);
573 if (IS_ERR(port->usb_sw)) {
574 ret = PTR_ERR(port->usb_sw);
575 goto err_unregister_mux;
581 typec_mux_unregister(port->typec_mux);
583 err_unregister_switch:
584 typec_switch_unregister(port->typec_sw);
589 /* IOM ACPI IDs and IOM_PORT_STATUS_OFFSET */
590 static const struct acpi_device_id iom_acpi_ids[] = {
592 { "INTC1072", 0x560, },
595 { "INTC1079", 0x160, },
598 { "INTC107A", 0x160, },
602 static int pmc_usb_probe_iom(struct pmc_usb *pmc)
604 struct list_head resource_list;
605 struct resource_entry *rentry;
606 static const struct acpi_device_id *dev_id;
607 struct acpi_device *adev = NULL;
610 for (dev_id = &iom_acpi_ids[0]; dev_id->id[0]; dev_id++) {
611 adev = acpi_dev_get_first_match_dev(dev_id->id, NULL, -1);
618 pmc->iom_port_status_offset = (u32)dev_id->driver_data;
620 INIT_LIST_HEAD(&resource_list);
621 ret = acpi_dev_get_memory_resources(adev, &resource_list);
627 rentry = list_first_entry_or_null(&resource_list, struct resource_entry, node);
629 pmc->iom_base = devm_ioremap_resource(pmc->dev, rentry->res);
631 acpi_dev_free_resource_list(&resource_list);
633 if (!pmc->iom_base) {
638 if (IS_ERR(pmc->iom_base)) {
640 return PTR_ERR(pmc->iom_base);
643 pmc->iom_adev = adev;
648 static int port_iom_status_show(struct seq_file *s, void *unused)
650 struct pmc_usb_port *port = s->private;
652 update_port_status(port);
653 seq_printf(s, "0x%08x\n", port->iom_status);
657 DEFINE_SHOW_ATTRIBUTE(port_iom_status);
659 static void pmc_mux_port_debugfs_init(struct pmc_usb_port *port)
661 struct dentry *debugfs_dir;
664 snprintf(name, sizeof(name), "port%d", port->usb3_port - 1);
666 debugfs_dir = debugfs_create_dir(name, port->pmc->dentry);
667 debugfs_create_file("iom_status", 0400, debugfs_dir, port,
668 &port_iom_status_fops);
671 static int pmc_usb_probe(struct platform_device *pdev)
673 struct fwnode_handle *fwnode = NULL;
678 pmc = devm_kzalloc(&pdev->dev, sizeof(*pmc), GFP_KERNEL);
682 device_for_each_child_node(&pdev->dev, fwnode)
685 /* The IOM microcontroller has a limitation of max 4 ports. */
686 if (pmc->num_ports > 4) {
687 dev_err(&pdev->dev, "driver limited to 4 ports\n");
691 pmc->port = devm_kcalloc(&pdev->dev, pmc->num_ports,
692 sizeof(struct pmc_usb_port), GFP_KERNEL);
696 pmc->ipc = devm_intel_scu_ipc_dev_get(&pdev->dev);
700 pmc->dev = &pdev->dev;
702 ret = pmc_usb_probe_iom(pmc);
706 pmc->dentry = debugfs_create_dir(dev_name(pmc->dev), pmc_mux_debugfs_root);
709 * For every physical USB connector (USB2 and USB3 combo) there is a
710 * child ACPI device node under the PMC mux ACPI device object.
712 for (i = 0; i < pmc->num_ports; i++) {
713 fwnode = device_get_next_child_node(pmc->dev, fwnode);
717 ret = pmc_usb_register_port(pmc, i, fwnode);
719 fwnode_handle_put(fwnode);
720 goto err_remove_ports;
723 pmc_mux_port_debugfs_init(&pmc->port[i]);
726 platform_set_drvdata(pdev, pmc);
731 for (i = 0; i < pmc->num_ports; i++) {
732 typec_switch_unregister(pmc->port[i].typec_sw);
733 typec_mux_unregister(pmc->port[i].typec_mux);
734 usb_role_switch_unregister(pmc->port[i].usb_sw);
737 acpi_dev_put(pmc->iom_adev);
739 debugfs_remove(pmc->dentry);
744 static void pmc_usb_remove(struct platform_device *pdev)
746 struct pmc_usb *pmc = platform_get_drvdata(pdev);
749 for (i = 0; i < pmc->num_ports; i++) {
750 typec_switch_unregister(pmc->port[i].typec_sw);
751 typec_mux_unregister(pmc->port[i].typec_mux);
752 usb_role_switch_unregister(pmc->port[i].usb_sw);
755 acpi_dev_put(pmc->iom_adev);
757 debugfs_remove(pmc->dentry);
760 static const struct acpi_device_id pmc_usb_acpi_ids[] = {
764 MODULE_DEVICE_TABLE(acpi, pmc_usb_acpi_ids);
766 static struct platform_driver pmc_usb_driver = {
768 .name = "intel_pmc_usb",
769 .acpi_match_table = ACPI_PTR(pmc_usb_acpi_ids),
771 .probe = pmc_usb_probe,
772 .remove_new = pmc_usb_remove,
775 static int __init pmc_usb_init(void)
777 pmc_mux_debugfs_root = debugfs_create_dir("intel_pmc_mux", usb_debug_root);
779 return platform_driver_register(&pmc_usb_driver);
781 module_init(pmc_usb_init);
783 static void __exit pmc_usb_exit(void)
785 platform_driver_unregister(&pmc_usb_driver);
786 debugfs_remove(pmc_mux_debugfs_root);
788 module_exit(pmc_usb_exit);
790 MODULE_AUTHOR("Heikki Krogerus <heikki.krogerus@linux.intel.com>");
791 MODULE_LICENSE("GPL v2");
792 MODULE_DESCRIPTION("Intel PMC USB mux control");