diff options
-rw-r--r-- | Documentation/devicetree/bindings/usb/fcs,fusb302.txt | 29 | ||||
-rw-r--r-- | drivers/staging/typec/fusb302/TODO | 4 | ||||
-rw-r--r-- | drivers/staging/typec/fusb302/fusb302.c | 18 |
3 files changed, 50 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt new file mode 100644 index 000000000000..472facfa5a71 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt | |||
@@ -0,0 +1,29 @@ | |||
1 | Fairchild FUSB302 Type-C Port controllers | ||
2 | |||
3 | Required properties : | ||
4 | - compatible : "fcs,fusb302" | ||
5 | - reg : I2C slave address | ||
6 | - interrupts : Interrupt specifier | ||
7 | |||
8 | Optional properties : | ||
9 | - fcs,max-sink-microvolt : Maximum voltage to negotiate when configured as sink | ||
10 | - fcs,max-sink-microamp : Maximum current to negotiate when configured as sink | ||
11 | - fcs,max-sink-microwatt : Maximum power to negotiate when configured as sink | ||
12 | If this is less then max-sink-microvolt * | ||
13 | max-sink-microamp then the configured current will | ||
14 | be clamped. | ||
15 | - fcs,operating-sink-microwatt : | ||
16 | Minimum amount of power accepted from a sink | ||
17 | when negotiating | ||
18 | |||
19 | Example: | ||
20 | |||
21 | fusb302: typec-portc@54 { | ||
22 | compatible = "fcs,fusb302"; | ||
23 | reg = <0x54>; | ||
24 | interrupt-parent = <&nmi_intc>; | ||
25 | interrupts = <0 IRQ_TYPE_LEVEL_LOW>; | ||
26 | fcs,max-sink-microvolt = <12000000>; | ||
27 | fcs,max-sink-microamp = <3000000>; | ||
28 | fcs,max-sink-microwatt = <36000000>; | ||
29 | }; | ||
diff --git a/drivers/staging/typec/fusb302/TODO b/drivers/staging/typec/fusb302/TODO index 4933a1d92c32..19b466eb585d 100644 --- a/drivers/staging/typec/fusb302/TODO +++ b/drivers/staging/typec/fusb302/TODO | |||
@@ -4,3 +4,7 @@ fusb302: | |||
4 | - Find a non-hacky way to coordinate between PM and I2C access | 4 | - Find a non-hacky way to coordinate between PM and I2C access |
5 | - Documentation? The FUSB302 datasheet provides information on the chip to help | 5 | - Documentation? The FUSB302 datasheet provides information on the chip to help |
6 | understand the code. But it may still be helpful to have a documentation. | 6 | understand the code. But it may still be helpful to have a documentation. |
7 | - We may want to replace the "fcs,max-snk-microvolt", "fcs,max-snk-microamp", | ||
8 | "fcs,max-snk-microwatt" and "fcs,operating-snk-microwatt" device(tree) | ||
9 | properties with properties which are part of a generic type-c controller | ||
10 | devicetree binding. | ||
diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c index 6baed06a3c0d..1c1751c994db 100644 --- a/drivers/staging/typec/fusb302/fusb302.c +++ b/drivers/staging/typec/fusb302/fusb302.c | |||
@@ -90,6 +90,7 @@ struct fusb302_chip { | |||
90 | struct i2c_client *i2c_client; | 90 | struct i2c_client *i2c_client; |
91 | struct tcpm_port *tcpm_port; | 91 | struct tcpm_port *tcpm_port; |
92 | struct tcpc_dev tcpc_dev; | 92 | struct tcpc_dev tcpc_dev; |
93 | struct tcpc_config tcpc_config; | ||
93 | 94 | ||
94 | struct regulator *vbus; | 95 | struct regulator *vbus; |
95 | 96 | ||
@@ -1198,7 +1199,6 @@ static const struct tcpc_config fusb302_tcpc_config = { | |||
1198 | 1199 | ||
1199 | static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev) | 1200 | static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev) |
1200 | { | 1201 | { |
1201 | fusb302_tcpc_dev->config = &fusb302_tcpc_config; | ||
1202 | fusb302_tcpc_dev->init = tcpm_init; | 1202 | fusb302_tcpc_dev->init = tcpm_init; |
1203 | fusb302_tcpc_dev->get_vbus = tcpm_get_vbus; | 1203 | fusb302_tcpc_dev->get_vbus = tcpm_get_vbus; |
1204 | fusb302_tcpc_dev->set_cc = tcpm_set_cc; | 1204 | fusb302_tcpc_dev->set_cc = tcpm_set_cc; |
@@ -1684,7 +1684,9 @@ static int fusb302_probe(struct i2c_client *client, | |||
1684 | { | 1684 | { |
1685 | struct fusb302_chip *chip; | 1685 | struct fusb302_chip *chip; |
1686 | struct i2c_adapter *adapter; | 1686 | struct i2c_adapter *adapter; |
1687 | struct device *dev = &client->dev; | ||
1687 | int ret = 0; | 1688 | int ret = 0; |
1689 | u32 v; | ||
1688 | 1690 | ||
1689 | adapter = to_i2c_adapter(client->dev.parent); | 1691 | adapter = to_i2c_adapter(client->dev.parent); |
1690 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { | 1692 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { |
@@ -1699,8 +1701,22 @@ static int fusb302_probe(struct i2c_client *client, | |||
1699 | chip->i2c_client = client; | 1701 | chip->i2c_client = client; |
1700 | i2c_set_clientdata(client, chip); | 1702 | i2c_set_clientdata(client, chip); |
1701 | chip->dev = &client->dev; | 1703 | chip->dev = &client->dev; |
1704 | chip->tcpc_config = fusb302_tcpc_config; | ||
1705 | chip->tcpc_dev.config = &chip->tcpc_config; | ||
1702 | mutex_init(&chip->lock); | 1706 | mutex_init(&chip->lock); |
1703 | 1707 | ||
1708 | if (!device_property_read_u32(dev, "fcs,max-sink-microvolt", &v)) | ||
1709 | chip->tcpc_config.max_snk_mv = v / 1000; | ||
1710 | |||
1711 | if (!device_property_read_u32(dev, "fcs,max-sink-microamp", &v)) | ||
1712 | chip->tcpc_config.max_snk_ma = v / 1000; | ||
1713 | |||
1714 | if (!device_property_read_u32(dev, "fcs,max-sink-microwatt", &v)) | ||
1715 | chip->tcpc_config.max_snk_mw = v / 1000; | ||
1716 | |||
1717 | if (!device_property_read_u32(dev, "fcs,operating-sink-microwatt", &v)) | ||
1718 | chip->tcpc_config.operating_snk_mw = v / 1000; | ||
1719 | |||
1704 | ret = fusb302_debugfs_init(chip); | 1720 | ret = fusb302_debugfs_init(chip); |
1705 | if (ret < 0) | 1721 | if (ret < 0) |
1706 | return ret; | 1722 | return ret; |