staging: typec: tcpci: move out of staging
Subsystems (5)
cover staging: typec: tcpci: move out of staging
This patch set attempts to move the tcpci driver out of staging by fix some tcpci driver issues and verified on NXP PTN5110, which is a standard tcpci typec port controller device with power delivery support, tested power source and sink with drp config.
Li Jun (12):
usb: typec: add API to get port type and preferred role
usb: typec: add basic typec properties
staging: typec: tcpci: add documentation for tcpci
staging: typec: tcpci: support port config passed via dt
staging: typec: tcpci: register port before request irq
staging: typec: tcpci: enable vbus detection
typec: tcpm: add starting value for drp toggling
staging: typec: tcpci: correct drp toggling
usb: typec: tcpm: only drives the connected cc line when attached
staging: typec: tcpci: update set_cc for different state
staging: typec: tcpci: Only touch target bit when enable vconn
staging: typec: tcpci: move tcpci driver out of staging
.../devicetree/bindings/usb/typec-tcpci.txt | 36 ++++
Documentation/devicetree/bindings/usb/typec.txt | 46 +++++
drivers/staging/Kconfig | 2 -
drivers/staging/Makefile | 1 -
drivers/staging/typec/Kconfig | 14 --
drivers/staging/typec/Makefile | 1 -
drivers/staging/typec/TODO | 5 -
drivers/usb/typec/Kconfig | 7 +
drivers/usb/typec/Makefile | 1 +
drivers/{staging => usb}/typec/tcpci.c | 185 ++++++++++++++++-----
drivers/{staging => usb}/typec/tcpci.h | 0
drivers/usb/typec/tcpm.c | 22 ++-
drivers/usb/typec/typec.c | 45 +++++
include/linux/usb/tcpm.h | 9 +-
include/linux/usb/typec.h | 2 +
15 files changed, 306 insertions(+), 70 deletions(-)
create mode 100644 Documentation/devicetree/bindings/usb/typec-tcpci.txt
create mode 100644 Documentation/devicetree/bindings/usb/typec.txt
delete mode 100644 drivers/staging/typec/Kconfig
delete mode 100644 drivers/staging/typec/Makefile
delete mode 100644 drivers/staging/typec/TODO
rename drivers/{staging => usb}/typec/tcpci.c (73%)
rename drivers/{staging => usb}/typec/tcpci.h (100%)Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1506398723-19359-1-git-send-email-jun.li-3arQi8VN3Tc@public.gmane.org
PATCH RESEND 1/12 usb: typec: add API to get port type and preferred role
This patch add 2 APIs to get port type and preferred role from firmware description.
--- drivers/usb/typec/typec.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/typec.h | 2 ++ 2 files changed, 47 insertions(+)
drivers/usb/typec/typec.c +45 -0
@@ -12,6 +12,7 @@#include <linux/device.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/of.h> #include <linux/slab.h> #include <linux/usb/typec.h>
@@ -1249,6 +1250,50 @@ void typec_set_pwr_opmode(struct typec_port *port, }EXPORT_SYMBOL_GPL (typec_set_pwr_opmode); +/** +* typec_get_port_type - Get the typec port type +* @dev: Device to get the property of +* +* This routine is used by typec hardware driver to read property port type +* from the device firmware description. +* +* Returns typec_port_type if success, otherwise negative error code. +*/ +int typec_get_port_type (struct device *dev) +{ +const char *type_str; +int ret; + + ret =device_property_read_string (dev,"port-type" , &type_str); +if (ret <0 ) +return ret; + +return match_string (typec_port_types,ARRAY_SIZE (typec_port_types), + type_str); +} +EXPORT_SYMBOL_GPL (typec_get_port_type); + +/** +* typec_get_power_role - Get the typec preferred role +* @dev: Device to get the property of +* +* This routine is used by typec hardware driver to read property default role +* from the device firmware description. +* +* Returns typec_role if success, otherwise negative error code. +*/ +int typec_get_power_role (struct device *dev) +{ +const char *power_str; +int ret; + + ret =device_property_read_string (dev,"default-role" , &power_str); +if (ret <0 ) +return ret; + +return match_string (typec_roles,ARRAY_SIZE (typec_roles), power_str); +} +EXPORT_SYMBOL_GPL (typec_get_power_role);/* --------------------------------------- */ /**
include/linux/usb/typec.h +2 -0
@@ -243,5 +243,7 @@ void typec_set_data_role(struct typec_port *port, enum typec_data_role role);void typec_set_pwr_role (struct typec_port *port,enum typec_role role);void typec_set_vconn_role (struct typec_port *port,enum typec_role role);void typec_set_pwr_opmode (struct typec_port *port,enum typec_pwr_opmode mode); +int typec_get_port_type (struct device *dev); +int typec_get_power_role (struct device *dev);#endif /* __LINUX_USB_TYPEC_H */
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 2/12 usb: typec: add basic typec properties
In reply to a message not in the archiveport-type is required for any typec port; default-role is only required for drp; power source capable needs src-pdos; power sink capable needs snk-pdos, max-snk-mv, max-snk-ma, op-snk-mw.
--- Documentation/devicetree/bindings/usb/typec.txt | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
Documentation/devicetree/bindings/usb/typec.txt new file +46 -0
@@ -0,0 +1,46 @@ +Generic typec and power delivery properties +------------------------------------------- + +Required properties: +- port-type: should be one of "source", "sink" or "dual". +- default-role: preferred power role if drp, should be "sink" or "source". +- src-pdos: An array of u32 with each entry providing supported power + source data object(PDO), the detailed bit definitions of + PDO can be found in "Universal Serial Bus Power Delivery + Specification" chapter 6.4.1.2 Source_Capabilities Message, + the order of each entry(PDO) should follow the PD spec chapter + 6.4.1. Required only for power source and power dual role with + power delivery support. +- snk-pdos: An array of u32 with each entry providing supported power + sink data object(PDO), the detailed bit definitions of PDO + can be found in "Universal Serial Bus Power Delivery + Specification" chapter 6.4.1.3 Sink Capabilities Message, + the order of each entry(PDO) should follow the PD spec chapter + 6.4.1. Required only for power sink and power dual role with + power delivery support. +- max-snk-mv: The max voltage the sink can support in millivoltage, required + only for power sink and power dual role with power delivery + support. +- max-snk-ma: The max current the sink can support in milliampere, required + only for power sink and power dual role with power delivery + support. +- op-snk-mw: Sink required operating power in milliwatts, if source offered + power is less then it, Capability Mismatch is set, required + only for power sink and power dual role with power delivery + support. + +Example: + +ptn5110@50 { + compatible = "usb,tcpci"; + reg = <0x50>; + interrupt-parent = <&gpio3>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + port-type = "dual"; + default-role = "sink"; + src-pdos = <0x380190c8>; + snk-pdos = <0x380190c8 0x3802d0c8>; + max-snk-mv = <9000>; + max-snk-ma = <1000>; + op-snk-mw = <9000>; +};
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1506398723-19359-3-git-send-email-jun.li-3arQi8VN3Tc@public.gmane.org
Re: [PATCH resend 02/12] usb: typec: add basic typec properties
Quoted 3 lines · Li Jun
port-type is required for any typec port; default-role is only required for drp; power source capable needs src-pdos; power sink capable needs snk-pdos, max-snk-mv, max-snk-ma, op-snk-mw.
"dt-bindings: usb: ..." for the subject prefix.
Quoted 12 lines
Signed-off-by Li Jun <[email protected]>--- Documentation/devicetree/bindings/usb/typec.txt | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+)Documentation/devicetree/bindings/usb/typec.txt new file +0
-0
Documentation/devicetree/bindings/usb/typec.txt line 2
Quoted 2 lines
Documentation/devicetree/bindings/usb/typec.txt new file +2
-0@@ -0,0 +1,46 @@ +Generic typec and power delivery properties +-------------------------------------------
What node do these apply to? A type C connector node? The PD microcontroller?
I'm reluctant to accept just a random list of properties without a more complete Type-C binding which I'd expect to have a connector node, OF graph ports to connect to video outputs, connection to USB controller, and connection to the PD controller.
Quoted 19 lines
Documentation/devicetree/bindings/usb/typec.txt new file +18
-0+ +Required properties: +- port-type: should be one of "source", "sink" or "dual". +- default-role: preferred power role if drp, should be "sink" or "source". +- src-pdos: An array of u32 with each entry providing supported power + source data object(PDO), the detailed bit definitions of + PDO can be found in "Universal Serial Bus Power Delivery + Specification" chapter 6.4.1.2 Source_Capabilities Message, + the order of each entry(PDO) should follow the PD spec chapter + 6.4.1. Required only for power source and power dual role with + power delivery support. +- snk-pdos: An array of u32 with each entry providing supported power + sink data object(PDO), the detailed bit definitions of PDO + can be found in "Universal Serial Bus Power Delivery + Specification" chapter 6.4.1.3 Sink Capabilities Message, + the order of each entry(PDO) should follow the PD spec chapter + 6.4.1. Required only for power sink and power dual role with + power delivery support.
Documentation/devicetree/bindings/usb/typec.txt line 30
Quoted 10 lines
Documentation/devicetree/bindings/usb/typec.txt new file +10
-0+- max-snk-mv: The max voltage the sink can support in millivoltage, required + only for power sink and power dual role with power delivery + support. +- max-snk-ma: The max current the sink can support in milliampere, required + only for power sink and power dual role with power delivery + support. +- op-snk-mw: Sink required operating power in milliwatts, if source offered + power is less then it, Capability Mismatch is set, required + only for power sink and power dual role with power delivery + support.
Use the standard unit suffixes as defined in property-units.txt
Quoted 23 lines
Documentation/devicetree/bindings/usb/typec.txt new file +16
-0+ +Example: + +ptn5110@50 { + compatible = "usb,tcpci"; + reg = <0x50>; + interrupt-parent = <&gpio3>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + port-type = "dual"; + default-role = "sink"; + src-pdos = <0x380190c8>; + snk-pdos = <0x380190c8 0x3802d0c8>; + max-snk-mv = <9000>; + max-snk-ma = <1000>; + op-snk-mw = <9000>; +};Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH resend 02/12] usb: typec: add basic typec properties
Hi Rob,
Quoted 10 lines
-----Original Message-----
From: Rob Herring [mailto:[email protected]]
Sent: Friday, October 06, 2017 4:44 AM
To: Jun Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; heikki.krogerus-VuQAYsv1563Yd54FQh9/[email protected]; [email protected]; o_leveque-1tsiiZ//[email protected]; Peter Chen <[email protected]>; A.s. Dong <[email protected]>; linux- [email protected]; [email protected]
Subject: Re: [PATCH resend 02/12] usb: typec: add basic typec properties
Quoted 7 lines
Quoted 3 lines · Li Jun
port-type is required for any typec port; default-role is only required for drp; power source capable needs src-pdos; power sink capable needs snk-pdos, max-snk-mv, max-snk-ma, op-snk-mw.
"dt-bindings: usb: ..." for the subject prefix.
Will update in next version.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Li Jun <[email protected]>--- Documentation/devicetree/bindings/usb/typec.txt | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
Quoted 12 lines
Documentation/devicetree/bindings/usb/typec.txt line 2
Quoted 9 lines
Documentation/devicetree/bindings/usb/typec.txt new file +2
-0@@ -0,0 +1,46 @@ +Generic typec and power delivery properties +-------------------------------------------What node do these apply to? A type C connector node? The PD microcontroller?
My initial thinking is those are general type-c properties, which can be applied to type-C connector or used by PD microcontroller directly (my example), I want to get inputs on how this can be handled properly, so do you think a separated node(e.g. type-c connector) is required to describe all the capability of the type-c port has, then a type-c related driver get the phandle of it?
Quoted 5 lines
I'm reluctant to accept just a random list of properties without a more complete Type-C binding which I'd expect to have a connector node, OF graph ports to connect to video outputs, connection to USB controller, and connection to the PD controller.
As type-C with PD has many properties to complete the description for diff usage, so this is just a first step to have the basic power related bindings.
Quoted 30 lines
Quoted 19 lines
Documentation/devicetree/bindings/usb/typec.txt new file +18
-0+ +Required properties: +- port-type: should be one of "source", "sink" or "dual". +- default-role: preferred power role if drp, should be "sink" or "source". +- src-pdos: An array of u32 with each entry providing supported power + source data object(PDO), the detailed bit definitions of + PDO can be found in "Universal Serial Bus Power Delivery + Specification" chapter 6.4.1.2 Source_Capabilities Message, + the order of each entry(PDO) should follow the PD spec chapter + 6.4.1. Required only for power source and power dual role with + power delivery support. +- snk-pdos: An array of u32 with each entry providing supported power + sink data object(PDO), the detailed bit definitions of PDO + can be found in "Universal Serial Bus Power Delivery + Specification" chapter 6.4.1.3 Sink Capabilities Message, + the order of each entry(PDO) should follow the PD spec chapter + 6.4.1. Required only for power sink and power dual role with + power delivery support.Documentation/devicetree/bindings/usb/typec.txt line 30
Quoted 10 lines
Documentation/devicetree/bindings/usb/typec.txt new file +10
-0+- max-snk-mv: The max voltage the sink can support in millivoltage, required + only for power sink and power dual role with power delivery + support. +- max-snk-ma: The max current the sink can support in milliampere, required + only for power sink and power dual role with power delivery + support. +- op-snk-mw: Sink required operating power in milliwatts, if source offered + power is less then it, Capability Mismatch is set, required + only for power sink and power dual role with power delivery + support.
Quoted 2 lines
Use the standard unit suffixes as defined in property-units.txt
Thanks, will update in next version.
Li Jun
Quoted 19 lines
Quoted 19 lines
Documentation/devicetree/bindings/usb/typec.txt new file +16
-1+ +Example: + +ptn5110@50 { + compatible = "usb,tcpci"; + reg = <0x50>; + interrupt-parent = <&gpio3>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + port-type = "dual"; + default-role = "sink"; + src-pdos = <0x380190c8>; + snk-pdos = <0x380190c8 0x3802d0c8>; + max-snk-mv = <9000>; + max-snk-ma = <1000>; + op-snk-mw = <9000>; +}; --2.6.6
Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe devicetree"
in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): DB4PR04MB07683A52DD500A40C2B9047A89740-tLF+feb1Bz6HC8XOQgzeLs9NdZoXdze2vxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH resend 02/12] usb: typec: add basic typec properties
Quoted 48 lines · Jun Li
Hi Rob,
Quoted 10 lines
-----Original Message-----
From: Rob Herring [mailto:[email protected]]
Sent: Friday, October 06, 2017 4:44 AM
To: Jun Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; heikki.krogerus-VuQAYsv1563Yd54FQh9/[email protected]; [email protected]; o_leveque-1tsiiZ//[email protected]; Peter Chen <[email protected]>; A.s. Dong <[email protected]>; linux- [email protected]; [email protected]
Subject: Re: [PATCH resend 02/12] usb: typec: add basic typec propertiesQuoted 7 lines
Quoted 3 lines · Li Jun
port-type is required for any typec port; default-role is only required for drp; power source capable needs src-pdos; power sink capable needs snk-pdos, max-snk-mv, max-snk-ma, op-snk-mw.
"dt-bindings: usb: ..." for the subject prefix.
Will update in next version.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Li Jun <[email protected]>--- Documentation/devicetree/bindings/usb/typec.txt | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+)Quoted 12 lines
Documentation/devicetree/bindings/usb/typec.txt line 2
Quoted 9 lines
Documentation/devicetree/bindings/usb/typec.txt new file +2
-0@@ -0,0 +1,46 @@ +Generic typec and power delivery properties +-------------------------------------------What node do these apply to? A type C connector node? The PD microcontroller?
My initial thinking is those are general type-c properties, which can be applied to type-C connector or used by PD microcontroller directly (my example), I want to get inputs on how this can be handled properly, so do you think a separated node(e.g. type-c connector) is required to describe all the capability of the type-c port has, then a type-c related driver get the phandle of it?
Quoted 8 lines
Quoted 5 lines
I'm reluctant to accept just a random list of properties without a more complete Type-C binding which I'd expect to have a connector node, OF graph ports to connect to video outputs, connection to USB controller, and connection to the PD controller.
As type-C with PD has many properties to complete the description for diff usage, so this is just a first step to have the basic power related bindings.
We need something more complete, not something that just evolves. At least the basic relationships between connectors, PD controller, alternate modes, and USB controllers needs to be defined.
Andrzej started on defining USB connectors[1]. That's where we need to start for Type-C bindings. Work together on this.
Rob
Quoted 35 lines
Quoted 29 lines
Quoted 18 lines
Documentation/devicetree/bindings/usb/typec.txt new file +17
-0+Required properties: +- port-type: should be one of "source", "sink" or "dual". +- default-role: preferred power role if drp, should be "sink" or "source". +- src-pdos: An array of u32 with each entry providing supported power + source data object(PDO), the detailed bit definitions of + PDO can be found in "Universal Serial Bus Power Delivery + Specification" chapter 6.4.1.2 Source_Capabilities Message, + the order of each entry(PDO) should follow the PD spec chapter + 6.4.1. Required only for power source and power dual role with + power delivery support. +- snk-pdos: An array of u32 with each entry providing supported power + sink data object(PDO), the detailed bit definitions of PDO + can be found in "Universal Serial Bus Power Delivery + Specification" chapter 6.4.1.3 Sink Capabilities Message, + the order of each entry(PDO) should follow the PD spec chapter + 6.4.1. Required only for power sink and power dual role with + power delivery support.Documentation/devicetree/bindings/usb/typec.txt line 30
Quoted 10 lines
Documentation/devicetree/bindings/usb/typec.txt new file +10
-0+- max-snk-mv: The max voltage the sink can support in millivoltage, required + only for power sink and power dual role with power delivery + support. +- max-snk-ma: The max current the sink can support in milliampere, required + only for power sink and power dual role with power delivery + support. +- op-snk-mw: Sink required operating power in milliwatts, if source offered + power is less then it, Capability Mismatch is set, required + only for power sink and power dual role with power delivery + support.Quoted 2 lines
Use the standard unit suffixes as defined in property-units.txt
Thanks, will update in next version.
Li Jun
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/usb/typec.txt new file +8
-0+ +Example: + +ptn5110@50 { + compatible = "usb,tcpci"; + reg = <0x50>; + interrupt-parent = <&gpio3>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>;Quoted 8 lines
Documentation/devicetree/bindings/usb/typec.txt line 46
Quoted 8 lines
Documentation/devicetree/bindings/usb/typec.txt new file +8
-0+ port-type = "dual"; + default-role = "sink"; + src-pdos = <0x380190c8>; + snk-pdos = <0x380190c8 0x3802d0c8>; + max-snk-mv = <9000>; + max-snk-ma = <1000>; + op-snk-mw = <9000>; +};
[1] http://www.spinics.net/lists/devicetree/msg197601.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 3/12 staging: typec: tcpci: add documentation for tcpci
In reply to a message not in the archiveTCPCI stands for typec port controller interface, its implementation has full typec port control with power delivery support, it's a standard i2c slave with GPIO input as irq interface, detail see spec "Universal Serial Bus Type-C Port Controller Interface Specification Revision 1.0, Version 1.1"
--- .../devicetree/bindings/usb/typec-tcpci.txt | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+)
Documentation/devicetree/bindings/usb/typec-tcpci.txt new file +36 -0
@@ -0,0 +1,36 @@ +TCPCI(Typec port cotroller interface) binding +--------------------------------------------- + +Required properties: +- compatible: should be "usb,tcpci". +- reg: the i2c slave address of typec port controller device. +- interrupt-parent: the phandle to the interrupt controller which provides + the interrupt. +- interrupts: interrupt specification for tcpci alert. +- port-type: typec port type. +- default-role: preferred power role if port type is "dual". + +Required properties only for power source or drp: +- src-pdos + +Required properties only for power sink or drp: +- snk-pdos +- max-snk-mv +- max-snk-ma +- op-snk-mw + +Example: + +ptn5110@50 { + compatible = "usb,tcpci"; + reg = <0x50>; + interrupt-parent = <&gpio3>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + port-type = "dual"; + default-role = "sink"; + src-pdos = <0x380190c8>; + snk-pdos = <0x380190c8 0x3802d0c8>; + max-snk-mv = <9000>; + max-snk-ma = <1000>; + op-snk-mw = <9000>; +};
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 4/12 staging: typec: tcpci: support port config passed via dt
In reply to a message not in the archiveUser can define the typec port properties in tcpci node to setup the port config.
--- drivers/staging/typec/tcpci.c | 89 +++++++++++++++++++++++++++++++++++++++---- include/linux/usb/tcpm.h | 6 +-- 2 files changed, 85 insertions(+), 10 deletions(-)
drivers/staging/typec/tcpci.c +82 -7
@@ -425,17 +425,92 @@ static const struct regmap_config tcpci_regmap_config = { .max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */ }; -static const struct tcpc_config tcpci_tcpc_config = { - .type =TYPEC_PORT_DFP , - .default_role =TYPEC_SINK , -}; - +/* Populate struct tcpc_config from device-tree */ static int tcpci_parse_config (struct tcpci *tcpci) { +struct tcpc_config *tcfg; +int ret = -EINVAL ; + tcpci->controls_vbus = true;/* XXX */ -/* TODO: Populate struct tcpc_config from ACPI/device-tree */ - tcpci->tcpc.config = &tcpci_tcpc_config; + tcpci->tcpc.config =devm_kzalloc (tcpci->dev,sizeof (*tcfg), +GFP_KERNEL ); +if (!tcpci->tcpc.config) +return -ENOMEM ; + + tcfg = tcpci->tcpc.config; + +/* Get port-type */ + ret =typec_get_port_type (tcpci->dev); +if (ret <0 ) { +dev_err (tcpci->dev,"typec port type is NOT correct!\n" ); +return ret; + } + tcfg->type = ret; + +if (tcfg->type ==TYPEC_PORT_UFP ) + goto sink; + +/* Get source PDO */ + tcfg->nr_src_pdo =device_property_read_u32_array (tcpci->dev, +"src-pdos" ,NULL ,0 ); +if (tcfg->nr_src_pdo <=0 ) { +dev_err (tcpci->dev,"typec source pdo is missing!\n" ); +return -EINVAL ; + } + + tcfg->src_pdo =devm_kzalloc (tcpci->dev, +sizeof (*tcfg->src_pdo) * tcfg->nr_src_pdo,GFP_KERNEL ); +if (!tcfg->src_pdo) +return -ENOMEM ; + + ret =device_property_read_u32_array (tcpci->dev,"src-pdos" , + tcfg->src_pdo, tcfg->nr_src_pdo); +if (ret) { +dev_err (tcpci->dev,"Failed to read src pdo!\n" ); +return -EINVAL ; + } + +if (tcfg->type ==TYPEC_PORT_DFP ) +return 0 ; + +/* Get the preferred power role for drp */ + ret =typec_get_power_role (tcpci->dev); +if (ret <0 ) { +dev_err (tcpci->dev,"typec preferred role is wrong!\n" ); +return ret; + } + tcfg->default_role = ret; +sink: +/* Get sink power capability */ + tcfg->nr_snk_pdo =device_property_read_u32_array (tcpci->dev, +"snk-pdos" ,NULL ,0 ); +if (tcfg->nr_snk_pdo <=0 ) { +dev_err (tcpci->dev,"typec sink pdo is missing!\n" ); +return -EINVAL ; + } + + tcfg->snk_pdo =devm_kzalloc (tcpci->dev, +sizeof (*tcfg->snk_pdo) * tcfg->nr_snk_pdo,GFP_KERNEL ); +if (!tcfg->snk_pdo) +return -ENOMEM ; + + ret =device_property_read_u32_array (tcpci->dev,"snk-pdos" , + tcfg->snk_pdo, tcfg->nr_snk_pdo); +if (ret) { +dev_err (tcpci->dev,"Failed to read sink pdo!\n" ); +return -EINVAL ; + } + +if (device_property_read_u32 (tcpci->dev,"max-snk-mv" , + &tcfg->max_snk_mv) || +device_property_read_u32 (tcpci->dev,"max-snk-ma" , + &tcfg->max_snk_ma) || +device_property_read_u32 (tcpci->dev,"op-snk-mw" , + &tcfg->operating_snk_mw)) { +dev_err (tcpci->dev,"Failed to read sink capability!\n" ); +return -EINVAL ; + }return 0 ; }
include/linux/usb/tcpm.h +3 -3
@@ -76,10 +76,10 @@ enum tcpm_transmit_type {* @alt_modes: List of supported alternate modes */ struct tcpc_config { -const u32 *src_pdo; +u32 *src_pdo;unsigned int nr_src_pdo; -const u32 *snk_pdo; +u32 *snk_pdo;unsigned int nr_snk_pdo;const u32 *snk_vdo;
@@ -154,7 +154,7 @@ struct tcpc_mux_dev {* @mux: Pointer to multiplexer data */ struct tcpc_dev { -const struct tcpc_config *config; +struct tcpc_config *config;int (*init)(struct tcpc_dev *dev);int (*get_vbus)(struct tcpc_dev *dev);
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 5/12 staging: typec: tcpci: register port before request irq
In reply to a message not in the archiveWith that we can clear any pending events and the port is registered so driver can be ready to handle typec events once we request irq.
--- drivers/staging/typec/tcpci.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/typec/tcpci.c +5 -3
@@ -552,15 +552,14 @@ static int tcpci_probe(struct i2c_client *client,/* Disable chip interrupts */ tcpci_write16 (tcpci,TCPC_ALERT_MASK ,0 ); - err =devm_request_threaded_irq (tcpci->dev, client->irq,NULL , + tcpci->port =tcpm_register_port (tcpci->dev, &tcpci->tcpc); +if (IS_ERR (tcpci->port)) +return PTR_ERR (tcpci->port); + +return devm_request_threaded_irq (tcpci->dev, client->irq,NULL , tcpci_irq,IRQF_ONESHOT |IRQF_TRIGGER_LOW ,dev_name (tcpci->dev), tcpci); -if (err <0 ) -return err;
PATCH RESEND 6/12 staging: typec: tcpci: enable vbus detection
In reply to a message not in the archiveTCPCI implementation may need SW to enable VBUS detection to generate power status events.
--- drivers/staging/typec/tcpci.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/staging/typec/tcpci.c +23 -0
@@ -313,6 +313,26 @@ static int tcpci_pd_transmit(struct tcpc_dev *tcpc,return 0 ; } +static int tcpci_vbus_detect (struct tcpc_dev *tcpc,bool enable) +{ +struct tcpci *tcpci =tcpc_to_tcpci (tcpc); +int ret; + +if (enable) { + ret =regmap_write (tcpci->regmap,TCPC_COMMAND , +TCPC_CMD_ENABLE_VBUS_DETECT ); +if (ret <0 ) +return ret; + }else { + ret =regmap_write (tcpci->regmap,TCPC_COMMAND , +TCPC_CMD_DISABLE_VBUS_DETECT ); +if (ret <0 ) +return ret; + } + +return 0 ; +} +static int tcpci_init (struct tcpc_dev *tcpc) {struct tcpci *tcpci =tcpc_to_tcpci (tcpc);
@@ -344,6 +364,9 @@ static int tcpci_init(struct tcpc_dev *tcpc)if (ret <0 )return ret; +/* Enable Vbus detection */ +tcpci_vbus_detect (tcpc, true); + reg =TCPC_ALERT_TX_SUCCESS |TCPC_ALERT_TX_FAILED |TCPC_ALERT_TX_DISCARDED |TCPC_ALERT_RX_STATUS |TCPC_ALERT_RX_HARD_RST |TCPC_ALERT_CC_STATUS ;
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 7/12 typec: tcpm: add starting value for drp toggling
In reply to a message not in the archiveAs DRP port autonomously toggles the Rp/Rd need a start value to begin with, so add one parameter for it in tcpm_start_drp_toggling.
--- drivers/usb/typec/tcpm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/usb/typec/tcpm.c +5 -5
@@ -1839,15 +1839,15 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)return 0 ; } -static bool tcpm_start_drp_toggling (struct tcpm_port *port) +static bool tcpm_start_drp_toggling (struct tcpm_port *port, +enum typec_cc_status cc) {int ret;if (port->tcpc->start_drp_toggling && port->port_type ==TYPEC_PORT_DRP ) {tcpm_log_force (port,"Start DRP toggling" ); - ret = port->tcpc->start_drp_toggling (port->tcpc, -tcpm_rp_cc (port)); + ret = port->tcpc->start_drp_toggling (port->tcpc, cc);if (!ret)return true; }
@@ -2156,7 +2156,7 @@ static void run_state_machine(struct tcpm_port *port)if (!port->non_pd_role_swap)tcpm_swap_complete (port, -ENOTCONN );tcpm_src_detach (port); -if (tcpm_start_drp_toggling (port)) { +if (tcpm_start_drp_toggling (port,tcpm_rp_cc (port))) {tcpm_set_state (port,DRP_TOGGLING ,0 );break ; }
@@ -2328,7 +2328,7 @@ static void run_state_machine(struct tcpm_port *port)if (!port->non_pd_role_swap)tcpm_swap_complete (port, -ENOTCONN );tcpm_snk_detach (port); -if (tcpm_start_drp_toggling (port)) { +if (tcpm_start_drp_toggling (port,TYPEC_CC_RD )) {tcpm_set_state (port,DRP_TOGGLING ,0 );break ; }
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 8/12 staging: typec: tcpci: correct drp toggling
In reply to a message not in the archivePer tcpci spec 4.4.5.2 ROLE_CONTROL description: "the TCPM shall write B6 (DRP) =1b and the starting value of Rp/Rd to B3..0 (CC1/CC2) to indicate DRP autonomous toggling mode to the TCPC", so add CC1/CC2 setting, also we should issue COMMAND.Look4Connection to start it.
--- drivers/staging/typec/tcpci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/staging/typec/tcpci.c +14 -1
@@ -109,6 +109,7 @@ static int tcpci_start_drp_toggling(struct tcpc_dev *tcpc, {struct tcpci *tcpci =tcpc_to_tcpci (tcpc);unsigned int reg =TCPC_ROLE_CTRL_DRP ; +int ret;switch (cc) {default :
@@ -126,7 +127,19 @@ static int tcpci_start_drp_toggling(struct tcpc_dev *tcpc,break ; } -return regmap_write (tcpci->regmap,TCPC_ROLE_CTRL , reg); +if (cc ==TYPEC_CC_RD ) + reg |= (TCPC_ROLE_CTRL_CC_RD <<TCPC_ROLE_CTRL_CC1_SHIFT ) | + (TCPC_ROLE_CTRL_CC_RD <<TCPC_ROLE_CTRL_CC2_SHIFT ); +else + reg |= (TCPC_ROLE_CTRL_CC_RP <<TCPC_ROLE_CTRL_CC1_SHIFT ) | + (TCPC_ROLE_CTRL_CC_RP <<TCPC_ROLE_CTRL_CC2_SHIFT ); + + ret =regmap_write (tcpci->regmap,TCPC_ROLE_CTRL , reg); +if (ret <0 ) +return ret; + +return regmap_write (tcpci->regmap,TCPC_COMMAND , +TCPC_CMD_LOOK4CONNECTION ); }static enum typec_cc_status tcpci_to_typec_cc (unsigned int cc,bool sink)
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 9/12 usb: typec: tcpm: only drives the connected cc line when attached
In reply to a message not in the archiveAs we should only drive connected cc line to be the right state when attached, and keeps the other one to be open, so update the set_cc interface for that.
--- drivers/usb/typec/tcpm.c | 12 +++++++++++- include/linux/usb/tcpm.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm.c +11 -1
@@ -1857,9 +1857,15 @@ static bool tcpm_start_drp_toggling(struct tcpm_port *port,static void tcpm_set_cc (struct tcpm_port *port,enum typec_cc_status cc) { +bool attached; +tcpm_log (port,"cc:=%d" , cc); port->cc_req = cc; - port->tcpc->set_cc (port->tcpc, cc); +if (port->state ==SRC_ATTACHED || port->state ==SNK_ATTACHED ) + attached = true; +else + attached = false; + port->tcpc->set_cc (port->tcpc, cc, attached, port->polarity); }static int tcpm_init_vbus (struct tcpm_port *port)
@@ -1913,6 +1919,8 @@ static int tcpm_src_attach(struct tcpm_port *port)if (ret <0 )return ret; +tcpm_set_cc (port,tcpm_rp_cc (port)); + ret =tcpm_set_roles (port, true,TYPEC_SOURCE ,TYPEC_HOST );if (ret <0 )return ret;
@@ -2028,6 +2036,8 @@ static int tcpm_snk_attach(struct tcpm_port *port)if (ret <0 )return ret; +tcpm_set_cc (port,TYPEC_CC_RD ); + ret =tcpm_set_roles (port, true,TYPEC_SINK ,TYPEC_DEVICE );if (ret <0 )return ret;
include/linux/usb/tcpm.h +2 -1
@@ -159,7 +159,8 @@ struct tcpc_dev {int (*init)(struct tcpc_dev *dev);int (*get_vbus)(struct tcpc_dev *dev);int (*get_current_limit)(struct tcpc_dev *dev); -int (*set_cc)(struct tcpc_dev *dev,enum typec_cc_status cc); +int (*set_cc)(struct tcpc_dev *dev,enum typec_cc_status cc, +bool attached,enum typec_cc_polarity polarity);int (*get_cc)(struct tcpc_dev *dev,enum typec_cc_status *cc1,enum typec_cc_status *cc2); int (*set_polarity)(struct tcpc_dev *dev,
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1506398723-19359-10-git-send-email-jun.li-3arQi8VN3Tc@public.gmane.org
kbuild test robot
build botRe: [PATCH resend 09/12] usb: typec: tcpm: only drives the connected cc line when attached
url: https://github.com/0day-ci/linux/commits/Li-Jun/staging-typec-tcpci-move-out-of-staging/20170927-190852 config: i386-allmodconfig (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0…
Hi Li,
[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.14-rc2 next-20170927]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Li-Jun/staging-typec-tcpci-move-out-of-staging/20170927-190852
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:
# save the attached .config to linux build tree
make ARCH=i386 Note: the linux-review/Li-Jun/staging-typec-tcpci-move-out-of-staging/20170927-190852 HEAD 9e1467d3603f3cee8f039d52010dfb8d33e2b29c builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
drivers/staging/typec/tcpci.c: In function 'tcpci_probe':
>> drivers/staging/typec/tcpci.c:574:21: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
tcpci->tcpc.set_cc = tcpci_set_cc;
^cc1: some warnings being treated as errors
vim +574 drivers/staging/typec/tcpci.c
74e656d6 Guenter Roeck 2017-04-27 553
74e656d6 Guenter Roeck 2017-04-27 554 static int tcpci_probe(struct i2c_client *client,
74e656d6 Guenter Roeck 2017-04-27 555 const struct i2c_device_id *i2c_id)
74e656d6 Guenter Roeck 2017-04-27 556 {
74e656d6 Guenter Roeck 2017-04-27 557 struct tcpci *tcpci;
74e656d6 Guenter Roeck 2017-04-27 558 int err;
74e656d6 Guenter Roeck 2017-04-27 559
74e656d6 Guenter Roeck 2017-04-27 560 tcpci = devm_kzalloc(&client->dev, sizeof(*tcpci), GFP_KERNEL);
74e656d6 Guenter Roeck 2017-04-27 561 if (!tcpci)
74e656d6 Guenter Roeck 2017-04-27 562 return -ENOMEM;
74e656d6 Guenter Roeck 2017-04-27 563
74e656d6 Guenter Roeck 2017-04-27 564 tcpci->client = client;
74e656d6 Guenter Roeck 2017-04-27 565 tcpci->dev = &client->dev;
74e656d6 Guenter Roeck 2017-04-27 566 i2c_set_clientdata(client, tcpci);
74e656d6 Guenter Roeck 2017-04-27 567 tcpci->regmap = devm_regmap_init_i2c(client, &tcpci_regmap_config);
74e656d6 Guenter Roeck 2017-04-27 568 if (IS_ERR(tcpci->regmap))
74e656d6 Guenter Roeck 2017-04-27 569 return PTR_ERR(tcpci->regmap);
74e656d6 Guenter Roeck 2017-04-27 570
74e656d6 Guenter Roeck 2017-04-27 571 tcpci->tcpc.init = tcpci_init;
74e656d6 Guenter Roeck 2017-04-27 572 tcpci->tcpc.get_vbus = tcpci_get_vbus;
74e656d6 Guenter Roeck 2017-04-27 573 tcpci->tcpc.set_vbus = tcpci_set_vbus;
74e656d6 Guenter Roeck 2017-04-27 @574 tcpci->tcpc.set_cc = tcpci_set_cc;
74e656d6 Guenter Roeck 2017-04-27 575 tcpci->tcpc.get_cc = tcpci_get_cc;
74e656d6 Guenter Roeck 2017-04-27 576 tcpci->tcpc.set_polarity = tcpci_set_polarity;
74e656d6 Guenter Roeck 2017-04-27 577 tcpci->tcpc.set_vconn = tcpci_set_vconn;
74e656d6 Guenter Roeck 2017-04-27 578 tcpci->tcpc.start_drp_toggling = tcpci_start_drp_toggling;
74e656d6 Guenter Roeck 2017-04-27 579
74e656d6 Guenter Roeck 2017-04-27 580 tcpci->tcpc.set_pd_rx = tcpci_set_pd_rx;
74e656d6 Guenter Roeck 2017-04-27 581 tcpci->tcpc.set_roles = tcpci_set_roles;
74e656d6 Guenter Roeck 2017-04-27 582 tcpci->tcpc.pd_transmit = tcpci_pd_transmit;
74e656d6 Guenter Roeck 2017-04-27 583
74e656d6 Guenter Roeck 2017-04-27 584 err = tcpci_parse_config(tcpci);
74e656d6 Guenter Roeck 2017-04-27 585 if (err < 0)
74e656d6 Guenter Roeck 2017-04-27 586 return err;
74e656d6 Guenter Roeck 2017-04-27 587
74e656d6 Guenter Roeck 2017-04-27 588 /* Disable chip interrupts */
74e656d6 Guenter Roeck 2017-04-27 589 tcpci_write16(tcpci, TCPC_ALERT_MASK, 0);
74e656d6 Guenter Roeck 2017-04-27 590
d94372b5 Li Jun 2017-09-26 591 tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc);
d94372b5 Li Jun 2017-09-26 592 if (IS_ERR(tcpci->port))
d94372b5 Li Jun 2017-09-26 593 return PTR_ERR(tcpci->port);
d94372b5 Li Jun 2017-09-26 594
d94372b5 Li Jun 2017-09-26 595 return devm_request_threaded_irq(tcpci->dev, client->irq, NULL,
74e656d6 Guenter Roeck 2017-04-27 596 tcpci_irq,
74e656d6 Guenter Roeck 2017-04-27 597 IRQF_ONESHOT | IRQF_TRIGGER_LOW,
74e656d6 Guenter Roeck 2017-04-27 598 dev_name(tcpci->dev), tcpci);
74e656d6 Guenter Roeck 2017-04-27 599 }
74e656d6 Guenter Roeck 2017-04-27 600 :::::: The code at line 574 was first introduced by commit
:::::: 74e656d6b0551999194b5ab1e45ff8b1e82b898e staging: typec: Type-C Port Controller Interface driver (tcpci)
:::::: TO: Guenter Roeck <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH RESEND 10/12 staging: typec: tcpci: update set_cc for different state
In reply to a message not in the archiveAs we should keep the disconnected cc line to be open when attached, so update the set_cc interface accordingly for it.
--- drivers/staging/typec/tcpci.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-)
drivers/staging/typec/tcpci.c +21 -16
@@ -57,10 +57,11 @@ static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val)return regmap_raw_write (tcpci->regmap, reg, &val,sizeof (u16)); } -static int tcpci_set_cc (struct tcpc_dev *tcpc,enum typec_cc_status cc) +static int tcpci_set_cc (struct tcpc_dev *tcpc,enum typec_cc_status cc, +bool attached,enum typec_cc_polarity polarity) {struct tcpci *tcpci =tcpc_to_tcpci (tcpc); -unsigned int reg; +unsigned int reg =0 , reg_cc1 =0 , reg_cc2 =0 ;int ret;switch (cc) {
@@ -69,26 +70,23 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) (TCPC_ROLE_CTRL_CC_RA <<TCPC_ROLE_CTRL_CC2_SHIFT );break ;case TYPEC_CC_RD : - reg = (TCPC_ROLE_CTRL_CC_RD <<TCPC_ROLE_CTRL_CC1_SHIFT ) | - (TCPC_ROLE_CTRL_CC_RD <<TCPC_ROLE_CTRL_CC2_SHIFT ); + reg_cc1 =TCPC_ROLE_CTRL_CC_RD <<TCPC_ROLE_CTRL_CC1_SHIFT ; + reg_cc2 =TCPC_ROLE_CTRL_CC_RD <<TCPC_ROLE_CTRL_CC2_SHIFT ;break ;case TYPEC_CC_RP_DEF : - reg = (TCPC_ROLE_CTRL_CC_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AL_SHIFT ;break ;case TYPEC_CC_OPEN :default :
@@ -97,6 +95,13 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)break ; } +if (!attached) + reg |= reg_cc1 | reg_cc2; +else if (polarity ==TYPEC_POLARITY_CC1 ) + reg |= reg_cc1; +else + reg |= reg_cc2; + ret =regmap_write (tcpci->regmap,TCPC_ROLE_CTRL , reg);if (ret <0 )return ret;
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 11/12 staging: typec: tcpci: Only touch target bit when enable vconn
In reply to a message not in the archiveWe need regmap_update_bits to avoid touch any other bits when enable or disable vconn.
--- drivers/staging/typec/tcpci.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/staging/typec/tcpci.c +3 -7
@@ -202,14 +202,10 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc,static int tcpci_set_vconn (struct tcpc_dev *tcpc,bool enable) {struct tcpci *tcpci =tcpc_to_tcpci (tcpc); -int ret; - ret =regmap_write (tcpci->regmap,TCPC_POWER_CTRL , - enable ?TCPC_POWER_CTRL_VCONN_ENABLE :0 ); -if (ret <0 ) -return ret; - -return 0 ; +return regmap_update_bits (tcpci->regmap,TCPC_POWER_CTRL , +TCPC_POWER_CTRL_VCONN_ENABLE , + enable ?TCPC_POWER_CTRL_VCONN_ENABLE :0 ); } static int tcpci_set_roles(struct tcpc_dev *tcpc, bool attached,
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND 12/12 staging: typec: tcpci: move tcpci driver out of staging
In reply to a message not in the archiveMove TCPCI(Typec port controller interface) driver out of staging.
---
drivers/staging/Kconfig | 2 --
drivers/staging/Makefile | 1 -
drivers/staging/typec/Kconfig | 14 --------------
drivers/staging/typec/Makefile | 1 -
drivers/staging/typec/TODO | 5 -----
drivers/usb/typec/Kconfig | 7 +++++++
drivers/usb/typec/Makefile | 1 +
drivers/{staging => usb}/typec/tcpci.c | 0
drivers/{staging => usb}/typec/tcpci.h | 0
9 files changed, 8 insertions(+), 23 deletions(-)drivers/staging/Kconfig +0 -2
@@ -112,8 +112,6 @@ source "drivers/staging/vc04_services/Kconfig" source "drivers/staging/ccree/Kconfig" -source "drivers/staging/typec/Kconfig" - source "drivers/staging/vboxvideo/Kconfig" source "drivers/staging/pi433/Kconfig"
drivers/staging/Makefile +0 -1
@@ -1,7 +1,6 @@ # Makefile for staging directory obj-y += media/ -obj-y += typec/ obj-$(CONFIG_IRDA) += irda/net/ obj-$(CONFIG_IRDA) += irda/drivers/ obj-$(CONFIG_PRISM2_USB) += wlan-ng/
drivers/staging/typec/Kconfig deleted +0 -14
@@ -1,14 +0,0 @@ -menu "USB Power Delivery and Type-C drivers" - -if TYPEC_TCPM - -config TYPEC_TCPCI - tristate "Type-C Port Controller Interface driver" - depends on I2C - select REGMAP_I2C - help - Type-C Port Controller driver for TCPCI-compliant controller. - -endif - -endmenu
drivers/staging/typec/Makefile deleted +0 -1
@@ -1 +0,0 @@ -obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o
drivers/staging/typec/TODO deleted +0 -5
@@ -1,5 +0,0 @@ -tcpci: -- Test with real hardware - -Please send patches to Guenter Roeck <[email protected]> and copy -Heikki Krogerus <heikki.krogerus-VuQAYsv1563Yd54FQh9/[email protected]>.
drivers/usb/typec/Kconfig +7 -0
@@ -14,6 +14,13 @@ config TYPEC_TCPM if TYPEC_TCPM +config TYPEC_TCPCI + tristate "Type-C Port Controller Interface driver" + depends on I2C + select REGMAP_I2C + help + Type-C Port Controller driver for TCPCI-compliant controller. + source "drivers/usb/typec/fusb302/Kconfig" endif
drivers/usb/typec/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_TYPEC_TCPM) += tcpm.o obj-y += fusb302/ obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o obj-$(CONFIG_TYPEC_UCSI) += ucsi/ +obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o
drivers/usb/typec/tcpci.c renamed from drivers/staging/typec/tcpci.c +0 -0
drivers/usb/typec/tcpci.h renamed from drivers/staging/typec/tcpci.h +0 -0
Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
What happened with this series ? Did we all drop the ball ?
Guenter
Quoted 35 lines · Li Jun
This patch set attempts to move the tcpci driver out of staging by fix some tcpci driver issues and verified on NXP PTN5110, which is a standard tcpci typec port controller device with power delivery support, tested power source and sink with drp config.
Li Jun (12):
usb: typec: add API to get port type and preferred role
usb: typec: add basic typec properties
staging: typec: tcpci: add documentation for tcpci
staging: typec: tcpci: support port config passed via dt
staging: typec: tcpci: register port before request irq
staging: typec: tcpci: enable vbus detection
typec: tcpm: add starting value for drp toggling
staging: typec: tcpci: correct drp toggling
usb: typec: tcpm: only drives the connected cc line when attached
staging: typec: tcpci: updateset_ccfor different state
staging: typec: tcpci: Only touch target bit when enable vconn
staging: typec: tcpci: move tcpci driver out of staging.../devicetree/bindings/usb/typec-tcpci.txt | 36 ++++ Documentation/devicetree/bindings/usb/typec.txt | 46 +++++ drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/typec/Kconfig | 14 -- drivers/staging/typec/Makefile | 1 - drivers/staging/typec/TODO | 5 - drivers/usb/typec/Kconfig | 7 + drivers/usb/typec/Makefile | 1 + drivers/{staging => usb}/typec/tcpci.c | 185 ++++++++++++++++----- drivers/{staging => usb}/typec/tcpci.h | 0 drivers/usb/typec/tcpm.c | 22 ++- drivers/usb/typec/typec.c | 45 +++++ include/linux/usb/tcpm.h | 9 +- include/linux/usb/typec.h | 2 + 15 files changed, 306 insertions(+), 70 deletions(-)
Quoted 8 lines
create mode 100644
Documentation/devicetree/bindings/usb/typec-tcpci.txtcreate mode 100644Documentation/devicetree/bindings/usb/typec.txtdelete mode 100644drivers/staging/typec/Kconfig
delete mode 100644drivers/staging/typec/Makefile
delete mode 100644drivers/staging/typec/TODO
renamedrivers/{staging=>usb}/typec/tcpci.c(73%)
renamedrivers/{staging=>usb}/typec/tcpci.h(100%)
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 96d37f9b-f04d-f923-ec09-b25fd62a90be-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org
SGkgR3VlbnRlciwNCg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBHdWVu dGVyIFJvZWNrIFttYWlsdG86Z3JvZWNrN0BnbWFpbC5jb21dIE9uIEJlaGFsZiBPZiBHdWVudGVy IFJvZWNrDQo+IFNlbnQ6IEZyaWRheSwgT2N0b2JlciAyNywgMjAxNyA4OjQzIEFNDQo+IFRvOiBK dW4gTGkgPGp1bi5saUBueHAuY29tPjsgZ3JlZ2toQGxpbnV4Zm91bmRhdGlvbi5vcmc7IHJvYmgr ZHRAa2VybmVsLm9yZzsNCj4gbWFyay5ydXRsYW5kQGFybS5jb207IGhlaWtraS5rcm9nZXJ1c0Bs aW51eC5pbnRlbC5jb20NCj4gQ2M6IHl1ZXlhb0Bnb29nbGUuY29tOyBvX2xldmVxdWVAb3Jhbmdl LmZyOyBQZXRlciBDaGVuDQo+IDxwZXRlci5jaGVuQG54cC5jb20+OyBBLnMuIERvbmcgPGFpc2hl bmcuZG9uZ0BueHAuY29tPjsgbGludXgtDQo+IHVzYkB2Z2VyLmtlcm5lbC5vcmc7IGRldmljZXRy ZWVAdmdlci5rZXJuZWwub3JnDQo+IFN1YmplY3Q6IFJlOiBbUEFUQ0ggcmVzZW5kIDAwLzEyXSBz dGFnaW5nOiB0eXBlYzogdGNwY2k6IG1vdmUgb3V0IG9mIHN0YWdpbmcNC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hZ2luZzogdHlwZWM6IHRjcGNpOiBtb3ZlIHRjcGNpIGRyaXZlciBvdXQgb2Ygc3Rh Z2luZw0KPiA+DQo+ID4gICAuLi4vZGV2aWNldHJlZS9iaW5kaW5ncy91c2IvdHlwZWMtdGNwY2ku dHh0ICAgICAgICB8ICAzNiArKysrDQo+ID4gICBEb2N1bWVudGF0aW9uL2RldmljZXRyZWUvYmlu ZGluZ3MvdXNiL3R5cGVjLnR4dCAgICB8ICA0NiArKysrKw0KPiA+ICAgZHJpdmVycy9zdGFnaW5n L0tjb25maWcgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgIDIgLQ0KPiA+ICAgZHJpdmVy cy9zdGFnaW5nL01ha2VmaWxlICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgIDEgLQ0KPiA+ ICAgZHJpdmVycy9zdGFnaW5nL3R5cGVjL0tjb25maWcgICAgICAgICAgICAgICAgICAgICAgfCAg MTQgLS0NCj4gPiAgIGRyaXZlcnMvc3RhZ2luZy90eXBlYy9NYWtlZmlsZSAgICAgICAgICAgICAg ICAgICAgIHwgICAxIC0NCj4gPiAgIGRyaXZlcnMvc3RhZ2luZy90eXBlYy9UT0RPICAgICAgICAg ICAgICAgICAgICAgICAgIHwgICA1IC0NCj4gPiAgIGRyaXZlcnMvdXNiL3R5cGVjL0tjb25maWcg ICAgICAgICAgICAgICAgICAgICAgICAgIHwgICA3ICsNCj4gPiAgIGRyaXZlcnMvdXNiL3R5cGVj L01ha2VmaWxlICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAxICsNCj4gPiAgIGRyaXZlcnMv e3N0YWdpbmcgPT4gdXNifS90eXBlYy90Y3BjaS5jICAgICAgICAgICAgIHwgMTg1ICsrKysrKysr KysrKysrKystLS0tLQ0KPiA+ICAgZHJpdmVycy97c3RhZ2luZyA9PiB1c2J9L3R5cGVjL3RjcGNp LmggICAgICAgICAgICAgfCAgIDANCj4gPiAgIGRyaXZlcnMvdXNiL3R5cGVjL3RjcG0uYyAgICAg ICAgICAgICAgICAgICAgICAgICAgIHwgIDIyICsrLQ0KPiA+ICAgZHJpdmVycy91c2IvdHlwZWMv dHlwZWMuYyAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgNDUgKysrKysNCj4gPiAgIGluY2x1 ZGUvbGludXgvdXNiL3RjcG0uaCAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICA5ICstDQo+ ID4gICBpbmNsdWRlL2xpbnV4L3VzYi90eXBlYy5oICAgICAgICAgICAgICAgICAgICAgICAgICB8 ICAgMiArDQo+ID4gICAxNSBmaWxlcyBjaGFuZ2VkLCAzMDYgaW5zZXJ0aW9ucygrKSwgNzAgZGVs ZXRpb25zKC0pDQo+ID4gICBjcmVhdGUgbW9kZSAxMDA2NDQgRG9jdW1lbnRhdGlvbi9kZXZpY2V0 cmVlL2JpbmRpbmdzL3VzYi90eXBlYy10Y3BjaS50eHQNCj4gPiAgIGNyZWF0ZSBtb2RlIDEwMDY0 NCBEb2N1bWVudGF0aW9uL2RldmljZXRyZWUvYmluZGluZ3MvdXNiL3R5cGVjLnR4dA0KPiA+ICAg ZGVsZXRlIG1vZGUgMTAwNjQ0IGRyaXZlcnMvc3RhZ2luZy90eXBlYy9LY29uZmlnDQo+ID4gICBk ZWxldGUgbW9kZSAxMDA2NDQgZHJpdmVycy9zdGFnaW5nL3R5cGVjL01ha2VmaWxlDQo+ID4gICBk ZWxldGUgbW9kZSAxMDA2NDQgZHJpdmVycy9zdGFnaW5nL3R5cGVjL1RPRE8NCj4gPiAgIHJlbmFt ZSBkcml2ZXJzL3tzdGFnaW5nID0+IHVzYn0vdHlwZWMvdGNwY2kuYyAoNzMlKQ0KPiA+ICAgcmVu YW1lIGRyaXZlcnMve3N0YWdpbmcgPT4gdXNifS90eXBlYy90Y3BjaS5oICgxMDAlKQ0KPiA+DQoN Cg==
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html