Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: typec: fusb302: Get max snk mv/ma/mw from device-properties

This is board specific info so it should come from board config, such
as devicetree.

I've chosen to prefix these with "fcs," treating them as fusb302 driver
specific for now. We may want to revisit this and replace these with
properties which are part of a (to be written) generic type-c controller
devicetree binding.

Since this commit adds new dt-properties it also adds devicetree-bindings
documentation (which so far was absent for the fusb302 driver).

Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: devicetree@vger.kernel.org
Cc: "Yueyao (Nathan) Zhu" <yueyao@google.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Hans de Goede and committed by
Greg Kroah-Hartman
097578ec 9a8fc4dd

+50 -1
+29
Documentation/devicetree/bindings/usb/fcs,fusb302.txt
··· 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 + };
+4
drivers/staging/typec/fusb302/TODO
··· 4 4 - Find a non-hacky way to coordinate between PM and I2C access 5 5 - Documentation? The FUSB302 datasheet provides information on the chip to help 6 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.
+17 -1
drivers/staging/typec/fusb302/fusb302.c
··· 90 90 struct i2c_client *i2c_client; 91 91 struct tcpm_port *tcpm_port; 92 92 struct tcpc_dev tcpc_dev; 93 + struct tcpc_config tcpc_config; 93 94 94 95 struct regulator *vbus; 95 96 ··· 1199 1198 1200 1199 static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev) 1201 1200 { 1202 - fusb302_tcpc_dev->config = &fusb302_tcpc_config; 1203 1201 fusb302_tcpc_dev->init = tcpm_init; 1204 1202 fusb302_tcpc_dev->get_vbus = tcpm_get_vbus; 1205 1203 fusb302_tcpc_dev->set_cc = tcpm_set_cc; ··· 1684 1684 { 1685 1685 struct fusb302_chip *chip; 1686 1686 struct i2c_adapter *adapter; 1687 + struct device *dev = &client->dev; 1687 1688 int ret = 0; 1689 + u32 v; 1688 1690 1689 1691 adapter = to_i2c_adapter(client->dev.parent); 1690 1692 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { ··· 1701 1699 chip->i2c_client = client; 1702 1700 i2c_set_clientdata(client, chip); 1703 1701 chip->dev = &client->dev; 1702 + chip->tcpc_config = fusb302_tcpc_config; 1703 + chip->tcpc_dev.config = &chip->tcpc_config; 1704 1704 mutex_init(&chip->lock); 1705 + 1706 + if (!device_property_read_u32(dev, "fcs,max-sink-microvolt", &v)) 1707 + chip->tcpc_config.max_snk_mv = v / 1000; 1708 + 1709 + if (!device_property_read_u32(dev, "fcs,max-sink-microamp", &v)) 1710 + chip->tcpc_config.max_snk_ma = v / 1000; 1711 + 1712 + if (!device_property_read_u32(dev, "fcs,max-sink-microwatt", &v)) 1713 + chip->tcpc_config.max_snk_mw = v / 1000; 1714 + 1715 + if (!device_property_read_u32(dev, "fcs,operating-sink-microwatt", &v)) 1716 + chip->tcpc_config.operating_snk_mw = v / 1000; 1705 1717 1706 1718 ret = fusb302_debugfs_init(chip); 1707 1719 if (ret < 0)