summaryrefslogtreecommitdiffstats
path: root/drivers/usb/typec
Commit message (Collapse)AuthorAgeFilesLines
* usb: typec: tcpm: Try PD-2.0 if sink does not respond to 3.0 source-capsHans de Goede2019-03-191-1/+26
| | | | | | | | | | | | | | | | | | PD 2.0 sinks are supposed to accept src-capabilities with a 3.0 header and simply ignore any src PDOs which the sink does not understand such as PPS but some 2.0 sinks instead ignore the entire PD_DATA_SOURCE_CAP message, causing contract negotiation to fail. This commit fixes such sinks not working by re-trying the contract negotiation with PD-2.0 source-caps messages if we don't have a contract after PD_N_HARD_RESET_COUNT hard-reset attempts. The problem fixed by this commit was noticed with a Type-C to VGA dongle. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: Fix unchecked return valueGustavo A. R. Silva2019-03-191-2/+7
| | | | | | | | | | | | | | | | | | Currently there is no check on platform_get_irq() return value in case it fails, hence never actually reporting any errors and causing unexpected behavior when using such value as argument for function regmap_irq_get_virq(). Fix this by adding a proper check, a message error and return *irq* in case platform_get_irq() fails. Addresses-Coverity-ID: 1443899 ("Improper use of negative value") Fixes: d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: tps6598x: handle block writes separately with plain-I2C adaptersNikolaus Voss2019-02-211-6/+20
| | | | | | | | | | | | | | | | | | Commit 1a2f474d328f handles block _reads_ separately with plain-I2C adapters, but the problem described with regmap-i2c not handling SMBus block transfers (i.e. read and writes) correctly also exists with writes. As workaround, this patch adds a block write function the same way 1a2f474d328f adds a block read function. Fixes: 1a2f474d328f ("usb: typec: tps6598x: handle block reads separately with plain-I2C adapters") Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de> Cc: stable <stable@vger.kernel.org> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: mux: remove redundant check on variable matchColin Ian King2019-02-201-1/+1
| | | | | | | | | | | | All the code paths that lead to the return statement are where match is always true, hence the check to see if it is true is redundant and can be removed. Detected by CoverityScan, CID#14769672 ("Logically dead code") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: mux: Fix unsigned comparison with less than zeroYueHaibing2019-02-191-1/+1
| | | | | | | | | | | | | | | The return from the call to fwnode_property_read_u16_array is int, it can be a negative error code however this is being assigned to an size_t variable 'nval', hence the check is always false. Fix this by making 'nval' an int. Detected by Coccinelle ("Unsigned expression compared with zero: nval < 0") Fixes: 96a6d031ca99 ("usb: typec: mux: Find the muxes by also matching against the device node") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: mux: Find the muxes by also matching against the device nodeHeikki Krogerus2019-02-141-12/+74
| | | | | | | | | | | | | | When the connections are defined in firmware, struct device_connection will have the fwnode member pointing to the device node (struct fwnode_handle) of the requested device, and the endpoint will not be used at all in that case. Acked-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Jun Li <jun.li@nxp.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: Find the ports by also matching against the device nodeHeikki Krogerus2019-02-141-3/+21
| | | | | | | | | | | | | | When the connections are defined in firmware, struct device_connection will have the fwnode member pointing to the device node (struct fwnode_handle) of the requested device, and the endpoint will not be used at all in that case. Acked-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Jun Li <jun.li@nxp.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: Rationalize the API for the muxesHeikki Krogerus2019-02-142-9/+8Star
| | | | | | | | | | | | | | | | | | | | | | | Since with accessory modes there is no need for additional identification when requesting a handle to the mux, we can replace the second parameter that is passed to the typec_mux_get() function with a pointer to alternate mode description structure, and simply passing NULL with accessory modes. This change means the naming of the mux device connections can be updated. Alternate and Accessory Modes will both be handled with muxes named "mode-switch", and the orientation switches will be named "orientation-switch". Future identification of the alternate modes will be later done using device property "svid" of the mux. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Jun Li <jun.li@nxp.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: tps6598x: Check mode of operationHeikki Krogerus2019-02-141-4/+49
| | | | | | | | | | | | | | To prevent loading of the driver when the PD controller is still in some operational mode that the driver does not support, checking the mode in driver probe callback function. TI PD controllers may be in undefined mode of operation for example when the application code (firmware) is completely missing. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: tcpm: Remove unused functionsGuenter Roeck2019-02-131-60/+0Star
| | | | | | | | | | | | tcpm_update_source_capabilities() and tcpm_update_sink_capabilities() are not used anywhere, and I don't recall why I introduced those functions in the first place. Effectively that means that we don't know if they even work, or ever did. Lets remove them. Reported-by: Kyle Tso <kyletso@google.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Kyle Tso <kyletso@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge 5.0-rc6 into usb-nextGreg Kroah-Hartman2019-02-111-1/+2
|\ | | | | | | | | | | We need the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: typec: tcpm: Correct the PPS out_volt calculationKyle Tso2019-01-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When Sink negotiates PPS, the voltage range of selected PPS APDO might not cover the previous voltage (out_volt). If the previous out_volt is lower than the new min_volt, the output voltage in RDO might be set to an invalid value. For instance, supposed that the previous voltage is 5V, and the new voltage range in the APDO is 7V-12V. Then the output voltage in the RDO should not be set to 5V which is lower than the possible min_volt 7V. Fix this by choosing the maximal value between the previous voltage and the new min_volt first. And ensure that this value will not exceed the new max_volt. The new out_volt will fall within the new voltage range while being the closest value compared to the previous out_volt. Signed-off-by: Kyle Tso <kyletso@google.com> Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Fixes: c710d0bb76ff0 ("usb: typec: tcpm: Extend the matching rules on PPS APDO selection") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: ucsi: Remove debug.h fileHeikki Krogerus2019-02-083-67/+64Star
| | | | | | | | | | | | | | It's not needed. Moving everything from it to trace.c. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: Prepare alt mode enter/exit reporting for UCSI alt mode supportHeikki Krogerus2019-02-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because of UCSI, we have to support alt mode enter/exit reporting even when there is no alt mode driver bind to the alt mode device. With UCSI a firmware handles the alternate modes, and the modes are entered automatically from OS PoW. Changing typec_altmode_update_active() so that the driver module ref count is incremented/decremented only if there really is a driver for the alt mode. That avoids a NULL pointer dereference from happening when the driver is missing. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: displayport: Move the Configuration VDO helpers to the headerHeikki Krogerus2019-02-081-4/+0Star
| | | | | | | | | | | | | | | | | | | | The helpers used for reading and writing the pin assignment from and to the Configuration VDO will be useful in GPU drivers, and also UCSI driver after DisplayPort alt mode support is added to it. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: tpcm: improve error handling of tcpm_register_portJun Li2019-01-251-3/+5
| | | | | | | | | | | | | | | | | | Remove debugfs if tcpm register port fails. Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | USB: add missing SPDX lines to Kconfig and MakefilesGreg Kroah-Hartman2019-01-226-0/+10
|/ | | | | | | | There are a few remaining drivers/usb/ files that do not have SPDX identifiers in them, all of these are either Kconfig or Makefiles. Add the correct GPL-2.0 identifier to them to make scanning tools happy. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge tag 'usb-4.21-rc1' of ↵Linus Torvalds2018-12-292-19/+39
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb Pull USB/PHY updates from Greg KH: "Here is the big set of USB and PHY driver patches for 4.21-rc1. All of the usual bits are in here: - loads of USB gadget driver updates and additions - new device ids - phy driver updates - xhci reworks and new features - typec updates Full details are in the shortlog. All of these have been in linux-next for a long time with no reported issues" * tag 'usb-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (142 commits) USB: serial: option: add Fibocom NL678 series cdc-acm: fix abnormal DATA RX issue for Mediatek Preloader. usb: r8a66597: Fix a possible concurrency use-after-free bug in r8a66597_endpoint_disable() usb: typec: tcpm: Extend the matching rules on PPS APDO selection usb: typec: Improve Alt Mode documentation usb: musb: dsps: fix runtime pm for peripheral mode usb: musb: dsps: fix otg state machine USB: serial: pl2303: add ids for Hewlett-Packard HP POS pole displays usb: renesas_usbhs: add support for RZ/G2E usb: ehci-omap: Fix deferred probe for phy handling usb: roles: Add a description for the class to Kconfig usb: renesas_usbhs: mark PM functions as __maybe_unused usb: core: Remove unnecessary memset() usb: host: isp1362-hcd: convert to DEFINE_SHOW_ATTRIBUTE phy: qcom-qmp: Expose provided clocks to DT dt-bindings: phy-qcom-qmp: Move #clock-cells to child phy: qcom-qmp: Utilize fully-specified DT registers dt-bindings: phy-qcom-qmp: Fix register underspecification phy: ti: fix semicolon.cocci warnings phy: dphy: Add configuration helpers ...
| * usb: typec: tcpm: Extend the matching rules on PPS APDO selectionKyle Tso2018-12-191-15/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current matching rules ensure that the voltage range of selected Source Capability is entirely within the range defined in one of the Sink Capabilities. This is reasonable but not practical because Sink may not support wide range of voltage when sinking power while Source could advertise its capabilities in relatively wider range. For example, a Source PDO advertising 3.3V-11V@3A (9V Prog of Fixed Nominal Voltage) will not be selected if the Sink requires 5V-12V@3A PPS power. However, the Sink could work well if the requested voltage range in RDOs is 5V-11V@3A. Currently accepted: |--------- source -----| |----------- sink ---------------| Currently not accepted: |--------- source -----| |----------- sink ---------------| |--------- source -----| |----------- sink ---------------| |--------- source -----------------| |------ sink -------| To improve the usability, change the matching rules to what listed below: a. The Source PDO is selectable if any portion of the voltage range overlaps one of the Sink PDO's voltage range. b. The maximum operational voltage will be the lower one between the selected Source PDO and the matching Sink PDO. c. The maximum power will be the maximum operational voltage times the maximum current defined in the selected Source PDO d. Select the Source PDO with the highest maximum power Signed-off-by: Kyle Tso <kyletso@google.com> Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * staging: typec: fusb302: Rename fcs,extcon-name to linux,extcon-nameAndy Shevchenko2018-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we are going to use the same in Designware USB 3 driver, rename the property to be consistent across the drivers. No functional change intended. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Guenter Roeck <linux@roeck-us.net> Acked-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * Merge 4.20-rc4 into usb-nextGreg Kroah-Hartman2018-11-263-0/+319
| |\ | | | | | | | | | | | | | | | We want the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * | usb: typec: tcpm: charge current handling for sink during hard resetBadhri Jagan Sridharan2018-11-071-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During the initial connect to a non-pd port, sink would hard reset twice before deeming that the port partner is non-pd. TCPM sets the the charge path to false during the hard reset. This causes unnecessary connects/disconnects of charge path and makes port take longer to charge from the non-pd ports. Avoid this by not setting the charge path to false unless the partner has already identified to be pd capable. When partner is a pd port, set the charge path to false in SNK_HARD_RESET_SINK_OFF. Set the current limits to default value based of CC pull up and resume the charge path when port enters SNK_HARD_RESET_SINK_ON. Signed-off-by: Badhri Jagan Sridharan <badhri@google.com> Reviewed-by: Rob Herring <robh@kernel.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> -------- Changes in V3: Rebase on top of usb-next Changes in V2: Based on feedback of jackp@codeaurora.org - vsafe_5v_hard_reset flag from tcpc_config is removed - Patch only differentiates between pd port partner and non-pd port partner V1 version of the patch is here: https://lkml.org/lkml/2018/9/14/11 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * | usb: typec: tcpm: Do not disconnect link for self powered devicesBadhri Jagan Sridharan2018-11-071-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During HARD_RESET the data link is disconnected. For self powered device, the spec is advising against doing that. >From USB_PD_R3_0 7.1.5 Response to Hard Resets Device operation during and after a Hard Reset is defined as follows: Self-powered devices Should Not disconnect from USB during a Hard Reset (see Section 9.1.2). Bus powered devices will disconnect from USB during a Hard Reset due to the loss of their power source. Tackle this by letting TCPM know whether the device is self or bus powered. This overcomes unnecessary port disconnections from hard reset. Also, speeds up the enumeration time when connected to Type-A ports. Signed-off-by: Badhri Jagan Sridharan <badhri@google.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> --------- Version history: V3: Rebase on top of usb-next V2: Based on feedback from heikki.krogerus@linux.intel.com - self_powered added to the struct tcpm_port which is populated from a. "connector" node of the device tree in tcpm_fw_get_caps() b. "self_powered" node of the tcpc_config in tcpm_copy_caps Based on feedbase from linux@roeck-us.net - Code was refactored - SRC_HARD_RESET_VBUS_OFF sets the link state to false based on self_powered flag V1 located here: https://lkml.org/lkml/2018/9/13/94 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | | Merge tag 'platform-drivers-x86-v4.21-1' of ↵Linus Torvalds2018-12-251-4/+4
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.infradead.org/linux-platform-drivers-x86 Pull x86 platform driver updates from Andy Shevchenko: - The USB Power Delivery discrete components now can be enumerated by i2c-multi-instantiate driver via several resources under single ACPI device node (ACPI ID is INT3515). - Touchscreen support is added for the Mediacom Flexbook Edge 11. - Mellanox driver got fixed due to updates in their firmware. - The power management stub driver for AtomISP v2 is fixed in order to support Intel Baytrail SoCs where same quirk is needed for S0ix to work. - Special key handling has been fixed for Favorites hotkey on Thinkpad, and Screen LOCK on ASUS. - Ideapad Yoga 2 13 has no HW rfkill switch, thus, driver has been updated to support this. - Few cleanups related to debugfs have been made in Intel IPS and Intel PMC drivers. Besides that Intel PMC has been extended to show more detailed information about Latency Tolerance * tag 'platform-drivers-x86-v4.21-1' of git://git.infradead.org/linux-platform-drivers-x86: (41 commits) platform/x86: mlx-platform: Convert to use SPDX identifier Documentation/ABI: Add new attribute for mlxreg-io sysfs interfaces platform/x86: mlx-platform: Allow mlxreg-io driver activation for new systems platform/x86: mlx-platform: Fix LED configuration platform/x86: mlx-platform: Fix tachometer registers platform/x86: mlx-platform: Rename new systems product names platform/x86: mlx-platform: Add definitions for new registers platform/x86: intel_telemetry: convert to DEFINE_SHOW_ATTRIBUTE platform/x86: intel_pmc_core: convert to DEFINE_SHOW_ATTRIBUTE platform/x86: thinkpad_acpi: Cleanup quirks macros platform/x86: touchscreen_dmi: Add info for the Mediacom Flexbook Edge 11 platform/x86: Fix config space access for intel_atomisp2_pm platform/x86: Add the VLV ISP PCI ID to atomisp2_pm platform/x86: intel_ips: Convert to use DEFINE_SHOW_ATTRIBUTE macro platform/x86: intel_ips: Remove never happen condition platform/x86: intel_ips: NULL check before some freeing functions is not needed platform/x86: intel_ips: remove unnecessary checks in ips_debugfs_init iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper ACPI / scan: Create platform device for INT3515 ACPI nodes platform/x86: i2c-multi-instantiate: Allow to have same slaves ...
| * | ACPI / scan: Create platform device for INT3515 ACPI nodesAndy Shevchenko2018-12-031-4/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | The ACPI device with INT3515 _HID is representing a complex USB PD hardware infrastructure which includes several I2C slave ICs. We add an ID to the I2C multi instantiate list to enumerate all I2C slaves correctly. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
* / usb: typec: ucsi: add support for Cypress CCGxAjay Gupta2018-11-093-0/+319
|/ | | | | | | | | | | | Latest NVIDIA GPU cards have a Cypress CCGx Type-C controller over I2C interface. This UCSI I2C driver uses I2C bus driver interface for communicating with Type-C controller. Signed-off-by: Ajay Gupta <ajayg@nvidia.com> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* usb: typec: Fix copy/paste on typec_set_vconn_role() kerneldocStephen Boyd2018-10-091-1/+1
| | | | | | | | This must have been copy pasted from the function above. Fix it. Signed-off-by: Stephen Boyd <swboyd@chromium.org> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: tcpm: Report back negotiated PPS voltage and currentAdam Thomson2018-10-091-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Currently when requesting a specific voltage or current through the psy interface, for PPS, when reading back from that interface the values will always be the same as previously given, if the request was successful. However PPS only allows for 20mV voltage steps and 50mA current steps, and the psy class expects microvolt and micro amp requests, so inbetween values can be provided through this interface. Really when reading back the true values negotiated should be given, and not the ones originally asked for. To report the actual values negotiated with the Source, the values stored are now rounded down to the relevant step units prior to building the PPS request, so that those values are later correctly reported through the psy interface. In addition this improves the adjustments made to meet the operating power requirements of the platform, which previously could have been slightly out due to not using valid PPS units of voltage and current. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: remove set but not used variables 'snk_ma, min_mv'YueHaibing2018-10-021-5/+2Star
| | | | | | | | | | | | | | | | Fixes gcc '-Wunused-but-set-variable' warning: drivers/usb/typec/tcpm/tcpm.c: In function 'tcpm_pd_select_pps_apdo': drivers/usb/typec/tcpm/tcpm.c:2212:39: warning: variable 'snk_ma' set but not used [-Wunused-but-set-variable] drivers/usb/typec/tcpm/tcpm.c: In function 'tcpm_pd_build_pps_request': drivers/usb/typec/tcpm/tcpm.c:2405:37: warning: variable 'min_mv' set but not used [-Wunused-but-set-variable] Signed-off-by: YueHaibing <yuehaibing@huawei.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: typec: tcpm: Fix APDO PPS order checking to be based on voltageAdam Thomson2018-10-021-2/+2
| | | | | | | | | | | | | | | Current code mistakenly checks against max current to determine order but this should be max voltage. This commit fixes the issue so order is correctly determined, thus avoiding failure based on a higher voltage PPS APDO having a lower maximum current output, which is actually valid. Fixes: 2eadc33f40d4 ("typec: tcpm: Add core support for sink side PPS") Cc: <stable@vger.kernel.org> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge 4.19-rc6 into usb-nextGreg Kroah-Hartman2018-09-301-4/+13
|\ | | | | | | | | | | We want the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: typec: mux: Take care of driver module reference countingHeikki Krogerus2018-09-201-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Functions typec_mux_get() and typec_switch_get() already make sure that the mux device reference count is incremented, but the same must be done to the driver module as well to prevent the drivers from being unloaded in the middle of operation. This fixes a potential "BUG: unable to handle kernel paging request at ..." from happening. Fixes: 93dd2112c7b2 ("usb: typec: mux: Get the mux identifier from function parameter") Acked-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: fusb302: Resolve fixed power role contract setupAdam Thomson2018-09-281-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the controller is configured for a fixed power role (Source only or Sink only), attach does not proceed within the TCPM state machine as there is no CC event generated by this driver to update the CC line status. To rectify this, when CC is configured as Source or Sink we now make use of the hardware's automatic fixed Source or Sink toggling mechanism, which detects attaches in the same way as for DRP toggling. In this way the result of toggling is handled in the same way by the 'fusb302_handle_togdone()' function, and CC events are generated as expected for TCPM allowing a contract to be established. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: fusb302: Correct spelling mistake for toggling stateAdam Thomson2018-09-281-6/+6
| | | | | | | | | | | | | | | | | | | | | | There's a typo in the enum name of the 'OFF' state for toggling (TOGGLINE instead of TOGGLING). This commit resolves that trivial spelling inconsistency. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: Group all TCPCI/TCPM code togetherHeikki Krogerus2018-09-2013-58/+61
| | | | | | | | | | | | | | | | | | | | Moving all the drivers that depend on the Port Controller Manager under a new directory drivers/usb/typec/tcpm/ and making Guenter Roeck the designated reviewer of that code. Acked-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: fusb302: reorganizing the probe function a littleHeikki Krogerus2018-09-201-16/+9Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The debugfs needs to be initialized as the last step in probe in this case. The struct dentry *rootdir can't be pointing to anything unless driver probe really finishes successfully. It is also not necessary to clear the i2c clientdata if the probe fails, so removing the extra label used for that. Acked-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: class: Don't use port parent for getting mux handlesHeikki Krogerus2018-09-201-23/+15Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is not possible to use the parent of the port device when requesting mux handles as the parent may be a multiport USB Type-C or PD controller. The muxes must be assigned to the ports, not the controllers. This will also move the requesting of the muxes after the port device is initialized. Acked-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: fusb302: Populate tcpc fwnode for TCPM property handlingAdam Thomson2018-09-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | This update populates the tcpc handle's fwnode pointer with the child usb-connector node, if it exists, so that TCPM can perform generic property handling to define the ports capabilities. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | Merge 4.19-rc4 into usb-nextGreg Kroah-Hartman2018-09-162-4/+4
|\| | | | | | | | | | | We need the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb/typec: fix kernel-doc notation warning for typec_match_altmodeRandy Dunlap2018-09-051-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix kernel-doc warning for missing function parameter 'mode' description: ../drivers/usb/typec/bus.c:268: warning: Function parameter or member 'mode' not described in 'typec_match_altmode' Also fix typos for same function documentation. Fixes: 8a37d87d72f0 ("usb: typec: Bus type for alternate modes") Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: typec: fix kernel-doc parameter warningRandy Dunlap2018-09-051-1/+0Star
| | | | | | | | | | | | | | | | | | | | Fix kernel-doc warning (13 times): ../drivers/usb/typec/class.c:1497: warning: Excess function parameter 'drvdata' description in 'typec_port_register_altmode' Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | USB: typec: fsusb302: remove unused variables snk_pdo and toggling_mode_nameColin Ian King2018-09-101-11/+0Star
|/ | | | | | | | | | | | | | Variables snk_pdo and toggling_mode_name are defined but are not used and hence can be removed. Cleans up clang warnings: warning: 'snk_pdo' defined but not used [-Wunused-const-variable=] warning: 'toggling_mode_name' defined but not used [-Wunused-const-variable=] Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge 4.18-rc7 into usb-nextGreg Kroah-Hartman2018-07-301-1/+1
|\ | | | | | | | | | | We want the USB fixes in here as well to handle merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selectionAdam Thomson2018-07-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a bug in the sink PDO search code when trying to select a PPS APDO. The current code actually sets the starting index for searching to whatever value 'i' is, rather than choosing index 1 to avoid the first PDO (always 5V fixed). As a result, for sources which support PPS but whose PPS APDO index does not match with the supporting sink PPS APDO index for the platform, no valid PPS APDO will be found so this feature will not be permitted. Sadly in testing, both Source and Sink capabilities matched up and this was missed. Code is now updated to correctly set the start index to 1, and testing with additional PPS capable sources show this to work as expected. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Fixes: 2eadc33f40d4 ("typec: tcpm: Add core support for sink side PPS") Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | Merge 4.18-rc5 into usb-nextGreg Kroah-Hartman2018-07-161-2/+3
|\| | | | | | | | | | | We need the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * typec: tcpm: Correctly report power_supply current and voltage for non pd supplyHans de Goede2018-07-021-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit f2a8aa053c17 ("typec: tcpm: Represent source supply through power_supply") moved the code to register a power_supply representing the device supplying power to the type-C connector, from the fusb302 code to the generic tcpm code so that we have a psy reporting the supply voltage and current for all tcpm devices. This broke the reporting of current and voltage through the psy interface when supplied by a a non pd supply (5V, current as reported by get_current_limit). The cause of this breakage is port->supply_voltage and port->current_limit not being set in that case. This commit fixes this by setting port->supply_voltage and port->current_limit from tcpm_set_current_limit(). This commit also removes setting supply_voltage and current_limit from tcpm_reset_port() as that calls tcpm_set_current_limit(0, 0) which now already sets these to 0. Fixes: f2a8aa053c17 ("typec: tcpm: Represent source supply through...") Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: avoid format-overflow warningArnd Bergmann2018-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc-8 points out that the fix-byte buffer might be too small if desc->mode is a three-digit number: drivers/usb/typec/class.c: In function 'typec_register_altmode': drivers/usb/typec/class.c:502:32: error: '%d' directive writing between 1 and 3 bytes into a region of size 2 [-Werror=format-overflow=] sprintf(alt->group_name, "mode%d", desc->mode); ^~ drivers/usb/typec/class.c:502:27: note: directive argument in the range [0, 255] sprintf(alt->group_name, "mode%d", desc->mode); ^~~~~~~~ drivers/usb/typec/class.c:502:2: note: 'sprintf' output between 6 and 8 bytes into a destination of size 6 sprintf(alt->group_name, "mode%d", desc->mode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I assume this cannot happen in practice, but we can simply make the string long enough to avoid the warning. This uses the two padding bytes that already exist after the string. Fixes: 4ab8c18d4d67 ("usb: typec: Register a device for every mode") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: unlock dp->lock on error exit path, and also zero ret if successfulColin Ian King2018-07-061-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One of the error handling paths forgets to unlock dp->lock on the error exit path leading to a potential lock-up. Also the return path for a successful call to the function configuration_store can return an uninitialized error return code if dp->alt->active is false, so ensure ret is zeroed on the successful exit path to avoid garbage being returned. Detected by CoverityScan, CID#1471597 ("Unitialized scalar variable") Fixes: 0e3bb7d6894d ("usb: typec: Add driver for DisplayPort alternate mode") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: typec: fix dereference before null check on adevColin Ian King2018-07-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Pointer adev is being dereferenced before it is being sanity checked with a null pointer check, hence it is possible for a null pointer dereference to occur. Fix this by dereferencing adev only once it is null checked. Detected by CoverityScan, CID#1471598 ("Dereference before null check") Fixes: 8a37d87d72f0 ("usb: typec: Bus type for alternate modes") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | USB: typec: fsusb302: Drop empty set_current_limit implementationHans de Goede2018-07-021-12/+0Star
| | | | | | | | | | | | | | | | | | | | The set_current_limit tcpm_dev callback is optional and the tcpm core will already log the passed in values, so there is no need to have an empty implementation of this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>