1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for TI TPS6598x USB Power Delivery controller family
5 * Copyright (C) 2017, Intel Corporation
6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
10 #include <linux/acpi.h>
11 #include <linux/module.h>
13 #include <linux/power_supply.h>
14 #include <linux/regmap.h>
15 #include <linux/interrupt.h>
16 #include <linux/usb/typec.h>
17 #include <linux/usb/typec_altmode.h>
18 #include <linux/usb/role.h>
19 #include <linux/workqueue.h>
24 /* Register offsets */
25 #define TPS_REG_VID 0x00
26 #define TPS_REG_MODE 0x03
27 #define TPS_REG_CMD1 0x08
28 #define TPS_REG_DATA1 0x09
29 #define TPS_REG_INT_EVENT1 0x14
30 #define TPS_REG_INT_EVENT2 0x15
31 #define TPS_REG_INT_MASK1 0x16
32 #define TPS_REG_INT_MASK2 0x17
33 #define TPS_REG_INT_CLEAR1 0x18
34 #define TPS_REG_INT_CLEAR2 0x19
35 #define TPS_REG_SYSTEM_POWER_STATE 0x20
36 #define TPS_REG_STATUS 0x1a
37 #define TPS_REG_SYSTEM_CONF 0x28
38 #define TPS_REG_CTRL_CONF 0x29
39 #define TPS_REG_POWER_STATUS 0x3f
40 #define TPS_REG_RX_IDENTITY_SOP 0x48
41 #define TPS_REG_DATA_STATUS 0x5f
43 /* TPS_REG_SYSTEM_CONF bits */
44 #define TPS_SYSCONF_PORTINFO(c) ((c) & 7)
48 TPS_PORTINFO_SINK_ACCESSORY,
50 TPS_PORTINFO_DRP_UFP_DRD,
52 TPS_PORTINFO_DRP_DFP_DRD,
56 /* TPS_REG_RX_IDENTITY_SOP */
57 struct tps6598x_rx_identity_reg {
59 struct usb_pd_identity identity;
62 /* Standard Task return codes */
63 #define TPS_TASK_TIMEOUT 1
64 #define TPS_TASK_REJECTED 3
73 static const char *const modes[] = {
74 [TPS_MODE_APP] = "APP ",
75 [TPS_MODE_BOOT] = "BOOT",
76 [TPS_MODE_BIST] = "BIST",
77 [TPS_MODE_DISC] = "DISC",
80 /* Unrecognized commands will be replaced with "!CMD" */
81 #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321)
85 struct regmap *regmap;
86 struct mutex lock; /* device lock */
89 struct typec_port *port;
90 struct typec_partner *partner;
91 struct usb_pd_identity partner_identity;
92 struct usb_role_switch *role_sw;
93 struct typec_capability typec_cap;
95 struct power_supply *psy;
96 struct power_supply_desc psy_desc;
97 enum power_supply_usb_type usb_type;
101 struct delayed_work wq_poll;
102 irq_handler_t irq_handler;
105 static enum power_supply_property tps6598x_psy_props[] = {
106 POWER_SUPPLY_PROP_USB_TYPE,
107 POWER_SUPPLY_PROP_ONLINE,
110 static enum power_supply_usb_type tps6598x_psy_usb_types[] = {
111 POWER_SUPPLY_USB_TYPE_C,
112 POWER_SUPPLY_USB_TYPE_PD,
115 static const char *tps6598x_psy_name_prefix = "tps6598x-source-psy-";
118 * Max data bytes for Data1, Data2, and other registers. See ch 1.3.2:
119 * https://www.ti.com/lit/ug/slvuan1a/slvuan1a.pdf
121 #define TPS_MAX_LEN 64
124 tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len)
126 u8 data[TPS_MAX_LEN + 1];
129 if (len + 1 > sizeof(data))
132 if (!tps->i2c_protocol)
133 return regmap_raw_read(tps->regmap, reg, val, len);
135 ret = regmap_raw_read(tps->regmap, reg, data, len + 1);
142 memcpy(val, &data[1], len);
146 static int tps6598x_block_write(struct tps6598x *tps, u8 reg,
147 const void *val, size_t len)
149 u8 data[TPS_MAX_LEN + 1];
151 if (len + 1 > sizeof(data))
154 if (!tps->i2c_protocol)
155 return regmap_raw_write(tps->regmap, reg, val, len);
158 memcpy(&data[1], val, len);
160 return regmap_raw_write(tps->regmap, reg, data, len + 1);
163 static inline int tps6598x_read8(struct tps6598x *tps, u8 reg, u8 *val)
165 return tps6598x_block_read(tps, reg, val, sizeof(u8));
168 static inline int tps6598x_read16(struct tps6598x *tps, u8 reg, u16 *val)
170 return tps6598x_block_read(tps, reg, val, sizeof(u16));
173 static inline int tps6598x_read32(struct tps6598x *tps, u8 reg, u32 *val)
175 return tps6598x_block_read(tps, reg, val, sizeof(u32));
178 static inline int tps6598x_read64(struct tps6598x *tps, u8 reg, u64 *val)
180 return tps6598x_block_read(tps, reg, val, sizeof(u64));
183 static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val)
185 return tps6598x_block_write(tps, reg, &val, sizeof(u64));
189 tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val)
191 return tps6598x_block_write(tps, reg, val, 4);
194 static int tps6598x_read_partner_identity(struct tps6598x *tps)
196 struct tps6598x_rx_identity_reg id;
199 ret = tps6598x_block_read(tps, TPS_REG_RX_IDENTITY_SOP,
204 tps->partner_identity = id.identity;
209 static void tps6598x_set_data_role(struct tps6598x *tps,
210 enum typec_data_role role, bool connected)
212 enum usb_role role_val;
214 if (role == TYPEC_HOST)
215 role_val = USB_ROLE_HOST;
217 role_val = USB_ROLE_DEVICE;
220 role_val = USB_ROLE_NONE;
222 usb_role_switch_set_role(tps->role_sw, role_val);
223 typec_set_data_role(tps->port, role);
226 static int tps6598x_connect(struct tps6598x *tps, u32 status)
228 struct typec_partner_desc desc;
229 enum typec_pwr_opmode mode;
235 mode = TPS_POWER_STATUS_PWROPMODE(tps->pwr_status);
237 desc.usb_pd = mode == TYPEC_PWR_MODE_PD;
238 desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
239 desc.identity = NULL;
242 ret = tps6598x_read_partner_identity(tps);
245 desc.identity = &tps->partner_identity;
248 typec_set_pwr_opmode(tps->port, mode);
249 typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
250 typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
251 if (TPS_STATUS_TO_UPSIDE_DOWN(status))
252 typec_set_orientation(tps->port, TYPEC_ORIENTATION_REVERSE);
254 typec_set_orientation(tps->port, TYPEC_ORIENTATION_NORMAL);
255 typec_set_mode(tps->port, TYPEC_STATE_USB);
256 tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), true);
258 tps->partner = typec_register_partner(tps->port, &desc);
259 if (IS_ERR(tps->partner))
260 return PTR_ERR(tps->partner);
263 typec_partner_set_identity(tps->partner);
265 power_supply_changed(tps->psy);
270 static void tps6598x_disconnect(struct tps6598x *tps, u32 status)
272 if (!IS_ERR(tps->partner))
273 typec_unregister_partner(tps->partner);
275 typec_set_pwr_opmode(tps->port, TYPEC_PWR_MODE_USB);
276 typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
277 typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
278 typec_set_orientation(tps->port, TYPEC_ORIENTATION_NONE);
279 typec_set_mode(tps->port, TYPEC_STATE_SAFE);
280 tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), false);
282 power_supply_changed(tps->psy);
285 static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd,
286 size_t in_len, u8 *in_data,
287 size_t out_len, u8 *out_data)
289 unsigned long timeout;
293 ret = tps6598x_read32(tps, TPS_REG_CMD1, &val);
296 if (val && !INVALID_CMD(val))
300 ret = tps6598x_block_write(tps, TPS_REG_DATA1,
306 ret = tps6598x_write_4cc(tps, TPS_REG_CMD1, cmd);
310 /* XXX: Using 1s for now, but it may not be enough for every command. */
311 timeout = jiffies + msecs_to_jiffies(1000);
314 ret = tps6598x_read32(tps, TPS_REG_CMD1, &val);
317 if (INVALID_CMD(val))
320 if (time_is_before_jiffies(timeout))
325 ret = tps6598x_block_read(tps, TPS_REG_DATA1,
331 ret = tps6598x_block_read(tps, TPS_REG_DATA1, &val, sizeof(u8));
337 case TPS_TASK_TIMEOUT:
339 case TPS_TASK_REJECTED:
348 static int tps6598x_dr_set(struct typec_port *port, enum typec_data_role role)
350 const char *cmd = (role == TYPEC_DEVICE) ? "SWUF" : "SWDF";
351 struct tps6598x *tps = typec_get_drvdata(port);
355 mutex_lock(&tps->lock);
357 ret = tps6598x_exec_cmd(tps, cmd, 0, NULL, 0, NULL);
361 ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
365 if (role != TPS_STATUS_TO_TYPEC_DATAROLE(status)) {
370 tps6598x_set_data_role(tps, role, true);
373 mutex_unlock(&tps->lock);
378 static int tps6598x_pr_set(struct typec_port *port, enum typec_role role)
380 const char *cmd = (role == TYPEC_SINK) ? "SWSk" : "SWSr";
381 struct tps6598x *tps = typec_get_drvdata(port);
385 mutex_lock(&tps->lock);
387 ret = tps6598x_exec_cmd(tps, cmd, 0, NULL, 0, NULL);
391 ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
395 if (role != TPS_STATUS_TO_TYPEC_PORTROLE(status)) {
400 typec_set_pwr_role(tps->port, role);
403 mutex_unlock(&tps->lock);
408 static const struct typec_operations tps6598x_ops = {
409 .dr_set = tps6598x_dr_set,
410 .pr_set = tps6598x_pr_set,
413 static bool tps6598x_read_status(struct tps6598x *tps, u32 *status)
417 ret = tps6598x_read32(tps, TPS_REG_STATUS, status);
419 dev_err(tps->dev, "%s: failed to read status\n", __func__);
422 trace_tps6598x_status(*status);
427 static bool tps6598x_read_data_status(struct tps6598x *tps)
432 ret = tps6598x_read32(tps, TPS_REG_DATA_STATUS, &data_status);
434 dev_err(tps->dev, "failed to read data status: %d\n", ret);
437 trace_tps6598x_data_status(data_status);
442 static bool tps6598x_read_power_status(struct tps6598x *tps)
447 ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &pwr_status);
449 dev_err(tps->dev, "failed to read power status: %d\n", ret);
452 tps->pwr_status = pwr_status;
453 trace_tps6598x_power_status(pwr_status);
458 static void tps6598x_handle_plug_event(struct tps6598x *tps, u32 status)
462 if (status & TPS_STATUS_PLUG_PRESENT) {
463 ret = tps6598x_connect(tps, status);
465 dev_err(tps->dev, "failed to register partner\n");
467 tps6598x_disconnect(tps, status);
471 static irqreturn_t cd321x_interrupt(int irq, void *data)
473 struct tps6598x *tps = data;
478 mutex_lock(&tps->lock);
480 ret = tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event);
482 dev_err(tps->dev, "%s: failed to read events\n", __func__);
485 trace_cd321x_irq(event);
490 if (!tps6598x_read_status(tps, &status))
493 if (event & APPLE_CD_REG_INT_POWER_STATUS_UPDATE)
494 if (!tps6598x_read_power_status(tps))
497 if (event & APPLE_CD_REG_INT_DATA_STATUS_UPDATE)
498 if (!tps6598x_read_data_status(tps))
501 /* Handle plug insert or removal */
502 if (event & APPLE_CD_REG_INT_PLUG_EVENT)
503 tps6598x_handle_plug_event(tps, status);
506 tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event);
509 mutex_unlock(&tps->lock);
516 static irqreturn_t tps6598x_interrupt(int irq, void *data)
518 struct tps6598x *tps = data;
524 mutex_lock(&tps->lock);
526 ret = tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event1);
527 ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT2, &event2);
529 dev_err(tps->dev, "%s: failed to read events\n", __func__);
532 trace_tps6598x_irq(event1, event2);
534 if (!(event1 | event2))
537 if (!tps6598x_read_status(tps, &status))
540 if ((event1 | event2) & TPS_REG_INT_POWER_STATUS_UPDATE)
541 if (!tps6598x_read_power_status(tps))
544 if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE)
545 if (!tps6598x_read_data_status(tps))
548 /* Handle plug insert or removal */
549 if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT)
550 tps6598x_handle_plug_event(tps, status);
553 tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event1);
554 tps6598x_write64(tps, TPS_REG_INT_CLEAR2, event2);
557 mutex_unlock(&tps->lock);
564 /* Time interval for Polling */
565 #define POLL_INTERVAL 500 /* msecs */
566 static void tps6598x_poll_work(struct work_struct *work)
568 struct tps6598x *tps = container_of(to_delayed_work(work),
569 struct tps6598x, wq_poll);
571 tps->irq_handler(0, tps);
572 queue_delayed_work(system_power_efficient_wq,
573 &tps->wq_poll, msecs_to_jiffies(POLL_INTERVAL));
576 static int tps6598x_check_mode(struct tps6598x *tps)
581 ret = tps6598x_read32(tps, TPS_REG_MODE, (void *)mode);
585 switch (match_string(modes, ARRAY_SIZE(modes), mode)) {
589 dev_warn(tps->dev, "dead-battery condition\n");
594 dev_err(tps->dev, "controller in unsupported mode \"%s\"\n",
602 static const struct regmap_config tps6598x_regmap_config = {
605 .max_register = 0x7F,
608 static int tps6598x_psy_get_online(struct tps6598x *tps,
609 union power_supply_propval *val)
611 if (TPS_POWER_STATUS_CONNECTION(tps->pwr_status) &&
612 TPS_POWER_STATUS_SOURCESINK(tps->pwr_status)) {
620 static int tps6598x_psy_get_prop(struct power_supply *psy,
621 enum power_supply_property psp,
622 union power_supply_propval *val)
624 struct tps6598x *tps = power_supply_get_drvdata(psy);
628 case POWER_SUPPLY_PROP_USB_TYPE:
629 if (TPS_POWER_STATUS_PWROPMODE(tps->pwr_status) == TYPEC_PWR_MODE_PD)
630 val->intval = POWER_SUPPLY_USB_TYPE_PD;
632 val->intval = POWER_SUPPLY_USB_TYPE_C;
634 case POWER_SUPPLY_PROP_ONLINE:
635 ret = tps6598x_psy_get_online(tps, val);
645 static int cd321x_switch_power_state(struct tps6598x *tps, u8 target_state)
650 ret = tps6598x_read8(tps, TPS_REG_SYSTEM_POWER_STATE, &state);
654 if (state == target_state)
657 ret = tps6598x_exec_cmd(tps, "SSPS", sizeof(u8), &target_state, 0, NULL);
661 ret = tps6598x_read8(tps, TPS_REG_SYSTEM_POWER_STATE, &state);
665 if (state != target_state)
671 static int devm_tps6598_psy_register(struct tps6598x *tps)
673 struct power_supply_config psy_cfg = {};
674 const char *port_dev_name = dev_name(tps->dev);
677 psy_cfg.drv_data = tps;
678 psy_cfg.fwnode = dev_fwnode(tps->dev);
680 psy_name = devm_kasprintf(tps->dev, GFP_KERNEL, "%s%s", tps6598x_psy_name_prefix,
685 tps->psy_desc.name = psy_name;
686 tps->psy_desc.type = POWER_SUPPLY_TYPE_USB;
687 tps->psy_desc.usb_types = tps6598x_psy_usb_types;
688 tps->psy_desc.num_usb_types = ARRAY_SIZE(tps6598x_psy_usb_types);
689 tps->psy_desc.properties = tps6598x_psy_props;
690 tps->psy_desc.num_properties = ARRAY_SIZE(tps6598x_psy_props);
691 tps->psy_desc.get_property = tps6598x_psy_get_prop;
693 tps->usb_type = POWER_SUPPLY_USB_TYPE_C;
695 tps->psy = devm_power_supply_register(tps->dev, &tps->psy_desc,
697 return PTR_ERR_OR_ZERO(tps->psy);
700 static int tps6598x_probe(struct i2c_client *client)
702 irq_handler_t irq_handler = tps6598x_interrupt;
703 struct device_node *np = client->dev.of_node;
704 struct typec_capability typec_cap = { };
705 struct tps6598x *tps;
706 struct fwnode_handle *fwnode;
713 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
717 mutex_init(&tps->lock);
718 tps->dev = &client->dev;
720 tps->regmap = devm_regmap_init_i2c(client, &tps6598x_regmap_config);
721 if (IS_ERR(tps->regmap))
722 return PTR_ERR(tps->regmap);
724 ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
729 * Checking can the adapter handle SMBus protocol. If it can not, the
730 * driver needs to take care of block reads separately.
732 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
733 tps->i2c_protocol = true;
735 if (np && of_device_is_compatible(np, "apple,cd321x")) {
736 /* Switch CD321X chips to the correct system power state */
737 ret = cd321x_switch_power_state(tps, TPS_SYSTEM_POWER_STATE_S0);
741 /* CD321X chips have all interrupts masked initially */
742 mask1 = APPLE_CD_REG_INT_POWER_STATUS_UPDATE |
743 APPLE_CD_REG_INT_DATA_STATUS_UPDATE |
744 APPLE_CD_REG_INT_PLUG_EVENT;
746 irq_handler = cd321x_interrupt;
748 /* Enable power status, data status and plug event interrupts */
749 mask1 = TPS_REG_INT_POWER_STATUS_UPDATE |
750 TPS_REG_INT_DATA_STATUS_UPDATE |
751 TPS_REG_INT_PLUG_EVENT;
754 tps->irq_handler = irq_handler;
755 /* Make sure the controller has application firmware running */
756 ret = tps6598x_check_mode(tps);
760 ret = tps6598x_write64(tps, TPS_REG_INT_MASK1, mask1);
764 ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
767 trace_tps6598x_status(status);
769 ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, &conf);
774 * This fwnode has a "compatible" property, but is never populated as a
775 * struct device. Instead we simply parse it to read the properties.
776 * This breaks fw_devlink=on. To maintain backward compatibility
777 * with existing DT files, we work around this by deleting any
778 * fwnode_links to/from this fwnode.
780 fwnode = device_get_named_child_node(&client->dev, "connector");
782 fw_devlink_purge_absent_suppliers(fwnode);
784 tps->role_sw = fwnode_usb_role_switch_get(fwnode);
785 if (IS_ERR(tps->role_sw)) {
786 ret = PTR_ERR(tps->role_sw);
790 typec_cap.revision = USB_TYPEC_REV_1_2;
791 typec_cap.pd_revision = 0x200;
792 typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE;
793 typec_cap.driver_data = tps;
794 typec_cap.ops = &tps6598x_ops;
795 typec_cap.fwnode = fwnode;
797 switch (TPS_SYSCONF_PORTINFO(conf)) {
798 case TPS_PORTINFO_SINK_ACCESSORY:
799 case TPS_PORTINFO_SINK:
800 typec_cap.type = TYPEC_PORT_SNK;
801 typec_cap.data = TYPEC_PORT_UFP;
803 case TPS_PORTINFO_DRP_UFP_DRD:
804 case TPS_PORTINFO_DRP_DFP_DRD:
805 typec_cap.type = TYPEC_PORT_DRP;
806 typec_cap.data = TYPEC_PORT_DRD;
808 case TPS_PORTINFO_DRP_UFP:
809 typec_cap.type = TYPEC_PORT_DRP;
810 typec_cap.data = TYPEC_PORT_UFP;
812 case TPS_PORTINFO_DRP_DFP:
813 typec_cap.type = TYPEC_PORT_DRP;
814 typec_cap.data = TYPEC_PORT_DFP;
816 case TPS_PORTINFO_SOURCE:
817 typec_cap.type = TYPEC_PORT_SRC;
818 typec_cap.data = TYPEC_PORT_DFP;
825 ret = devm_tps6598_psy_register(tps);
829 tps->port = typec_register_port(&client->dev, &typec_cap);
830 if (IS_ERR(tps->port)) {
831 ret = PTR_ERR(tps->port);
835 if (status & TPS_STATUS_PLUG_PRESENT) {
836 ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status);
838 dev_err(tps->dev, "failed to read power status: %d\n", ret);
839 goto err_unregister_port;
841 ret = tps6598x_connect(tps, status);
843 dev_err(&client->dev, "failed to register partner\n");
847 ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
849 IRQF_SHARED | IRQF_ONESHOT,
850 dev_name(&client->dev), tps);
852 dev_warn(tps->dev, "Unable to find the interrupt, switching to polling\n");
853 INIT_DELAYED_WORK(&tps->wq_poll, tps6598x_poll_work);
854 queue_delayed_work(system_power_efficient_wq, &tps->wq_poll,
855 msecs_to_jiffies(POLL_INTERVAL));
861 i2c_set_clientdata(client, tps);
862 fwnode_handle_put(fwnode);
864 tps->wakeup = device_property_read_bool(tps->dev, "wakeup-source");
865 if (tps->wakeup && client->irq) {
866 device_init_wakeup(&client->dev, true);
867 enable_irq_wake(client->irq);
873 tps6598x_disconnect(tps, 0);
875 typec_unregister_port(tps->port);
877 usb_role_switch_put(tps->role_sw);
879 fwnode_handle_put(fwnode);
881 tps6598x_write64(tps, TPS_REG_INT_MASK1, 0);
885 static void tps6598x_remove(struct i2c_client *client)
887 struct tps6598x *tps = i2c_get_clientdata(client);
890 cancel_delayed_work_sync(&tps->wq_poll);
892 tps6598x_disconnect(tps, 0);
893 typec_unregister_port(tps->port);
894 usb_role_switch_put(tps->role_sw);
897 static int __maybe_unused tps6598x_suspend(struct device *dev)
899 struct i2c_client *client = to_i2c_client(dev);
900 struct tps6598x *tps = i2c_get_clientdata(client);
903 disable_irq(client->irq);
904 enable_irq_wake(client->irq);
908 cancel_delayed_work_sync(&tps->wq_poll);
913 static int __maybe_unused tps6598x_resume(struct device *dev)
915 struct i2c_client *client = to_i2c_client(dev);
916 struct tps6598x *tps = i2c_get_clientdata(client);
919 disable_irq_wake(client->irq);
920 enable_irq(client->irq);
924 queue_delayed_work(system_power_efficient_wq, &tps->wq_poll,
925 msecs_to_jiffies(POLL_INTERVAL));
930 static const struct dev_pm_ops tps6598x_pm_ops = {
931 SET_SYSTEM_SLEEP_PM_OPS(tps6598x_suspend, tps6598x_resume)
934 static const struct of_device_id tps6598x_of_match[] = {
935 { .compatible = "ti,tps6598x", },
936 { .compatible = "apple,cd321x", },
939 MODULE_DEVICE_TABLE(of, tps6598x_of_match);
941 static const struct i2c_device_id tps6598x_id[] = {
945 MODULE_DEVICE_TABLE(i2c, tps6598x_id);
947 static struct i2c_driver tps6598x_i2c_driver = {
950 .pm = &tps6598x_pm_ops,
951 .of_match_table = tps6598x_of_match,
953 .probe = tps6598x_probe,
954 .remove = tps6598x_remove,
955 .id_table = tps6598x_id,
957 module_i2c_driver(tps6598x_i2c_driver);
959 MODULE_AUTHOR("Heikki Krogerus <heikki.krogerus@linux.intel.com>");
960 MODULE_LICENSE("GPL v2");
961 MODULE_DESCRIPTION("TI TPS6598x USB Power Delivery Controller Driver");