Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1441498 > unrolled thread

[v5 PATCH 0/5] Rockchip Type-C and DisplayPort driver

Started byChris Zhong <zyw@rock-chips.com>
First post2016-07-12 17:20 +0200
Last post2016-07-14 04:20 +0200
Articles 11 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [v5 PATCH 0/5] Rockchip Type-C and DisplayPort driver Chris Zhong <zyw@rock-chips.com> - 2016-07-12 17:20 +0200
    [v5 PATCH 1/5] extcon: Add Type-C and DP support Chris Zhong <zyw@rock-chips.com> - 2016-07-12 17:20 +0200
      Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support Chanwoo Choi <cw00.choi@samsung.com> - 2016-07-13 03:20 +0200
        Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support Chris Zhong <zyw@rock-chips.com> - 2016-07-13 03:50 +0200
          Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support Chanwoo Choi <cw00.choi@samsung.com> - 2016-07-13 04:10 +0200
            Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support Chris Zhong <zyw@rock-chips.com> - 2016-07-13 05:00 +0200
              Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support Chanwoo Choi <cw00.choi@samsung.com> - 2016-07-14 03:00 +0200
                Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support Chris Zhong <zyw@rock-chips.com> - 2016-07-14 03:10 +0200
                  Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support Chanwoo Choi <cw00.choi@samsung.com> - 2016-07-14 03:20 +0200
                    Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support Chris Zhong <zyw@rock-chips.com> - 2016-07-14 04:10 +0200
                      Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support Chanwoo Choi <cw00.choi@samsung.com> - 2016-07-14 04:20 +0200

#1441498 — [v5 PATCH 0/5] Rockchip Type-C and DisplayPort driver

FromChris Zhong <zyw@rock-chips.com>
Date2016-07-12 17:20 +0200
Subject[v5 PATCH 0/5] Rockchip Type-C and DisplayPort driver
Message-ID<rU7Dz-6Gj-3@gated-at.bofh.it>
Hi all

This series patch is for rockchip Type-C phy and DisplayPort controller
driver.

The USB Type-C PHY is designed to support the USB3 and DP applications.
The PHY basically has two main components: USB3 and DisplyPort. USB3
operates in SuperSpeed mode and the DP can operate at RBR, HBR and HBR2
data rates. The Type-C cable orientation detection and Power Delivery
(PD) is accomplished using a PD PHY or a exernal PD chip.

The DP controller is compliant with DisplayPort Specification,
Version 1.3, This IP is compatible with the rockchip type-c PHY IP.
There is a uCPU in DP controller, it need a firmware to work, please
put the firmware file[0] to /lib/firmware/cdn/dptx.bin. The uCPU in charge
of aux communication and link training, the host use mailbox to
communicate with the ucpu.

The DP contoller has register a notification with extcon API, to get the
alt mode from PD, the PD driver need call the devm_extcon_dev_allocate
to create a extcon device and use extcon_set_state to notify DP
controller. And call extcon_set_cable_property to set orientation.

About the DP audio, cdn-dp registered 2 DAIs: 0 is I2S, 1 is SPDIF.
We can reference them in simple-card.

This series is based on Mark Yao's branch[1] and Chanwoo Choi's
extcon-test branch[2]

I test this patches on the rk3399-evb board, with a fusb302 driver,
this branch has no rk3399.dtsi, so the patch about dts is not included
in this series.

[0]
https://patchwork.kernel.org/patch/9225567/
[1]
https://github.com/markyzq/kernel-drm-rockchip/tree/drm-rockchip-next-2016-05-23
[2]
https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-test
- usb: dwc3: omap: Support the changed method to get the state of connector
- usb: chipdata: Support the changed method to get the state of connector
- extcon: Add the support for extcon property according to type of connector
- extcon: Add the extcon_type to group each connector into five category


Changes in v5:
- support get property
- support get property from extcon
- remove PIN ASSIGN A/B support
- alphabetical order
- do not use long, use u32 or u64
- return MODE_CLOCK_HIGH when requested > actual
- Optimized Coding Style
- add a formula to get better tu size and symbol value.

Changes in v4:
- add a #phy-cells node
- select EXTCON
- use phy framework to control the USB3 and DP function
- rename PIN_MAP_ to PIN_ASSIGN_
- add a reset node
- support 2 phys
- use phy framework to control DP phy
- support 2 phys

Changes in v3:
- use compatible: rockchip,rk3399-typec-phy
- use dashes instead of underscores.
- remove the phy framework(Kishon Vijay Abraham I)
- add parentheses around the macro
- use a single space between type and name
- add spaces after opening and before closing braces.
- use u16 for register value
- remove type-c phy header file
- CodingStyle optimization
- use some cable extcon to get type-c port information
- add a extcon to notify Display Port
- add SoC specific compatible string
- remove reg = <1>;
- use EXTCON_DISP_DP and EXTCON_DISP_DP_ALT cable to get dp port state.
- reset spdif before config it
- modify the firmware clk to 100Mhz
- retry load firmware if fw file is requested too early

Changes in v2:
- add some registers description
- select RESET_CONTROLLER
- alphabetic order
- modify some spelling mistakes
- make mode cleaner
- use bool for enable/disable
- check all of the return value
- return a better err number
- use more readx_poll_timeout()
- clk_disable_unprepare(tcphy->clk_ref);
- remove unuse functions, rockchip_typec_phy_power_on/off
- remove unnecessary typecast from void *
- use dts node to distinguish between phys.
- Alphabetic order
- remove excess error message
- use define clk_rate
- check all return value
- remove dev_set_name(dp->dev, "cdn-dp");
- use schedule_delayed_work
- remove never-called functions
- remove some unnecessary ()

Changes in v1:
- add extcon node description
- move the registers in phy driver
- remove the suffix of reset
- update the licence note
- init core clock to 50MHz
- use extcon API
- remove unused global
- add some comments for magic num
- change usleep_range(1000, 2000) tousleep_range(1000, 1050)
- remove __func__ from dev_err
- return err number when get clk failed
- remove ADDR_ADJ define
- use devm_clk_get(&pdev->dev, "tcpdcore")
- add extcon node description
- add #sound-dai-cells description
- use extcon API
- use hdmi-codec for the DP Asoc
- do not initialize the "ret"
- printk a err log when drm_of_encoder_active_endpoint_id
- modify the dclk pin_pol to a single line

Chris Zhong (5):
  extcon: Add Type-C and DP support
  Documentation: bindings: add dt doc for Rockchip USB Type-C PHY
  phy: Add USB Type-C PHY driver for rk3399
  Documentation: bindings: add dt documentation for cdn DP controller
  drm/rockchip: cdn-dp: add cdn DP support for rk3399

 .../bindings/display/rockchip/cdn-dp-rockchip.txt  |  67 ++
 .../devicetree/bindings/phy/phy-rockchip-typec.txt |  77 ++
 drivers/extcon/extcon.c                            |  28 +
 drivers/gpu/drm/rockchip/Kconfig                   |   9 +
 drivers/gpu/drm/rockchip/Makefile                  |   1 +
 drivers/gpu/drm/rockchip/cdn-dp-core.c             | 761 ++++++++++++++++
 drivers/gpu/drm/rockchip/cdn-dp-core.h             | 113 +++
 drivers/gpu/drm/rockchip/cdn-dp-reg.c              | 740 ++++++++++++++++
 drivers/gpu/drm/rockchip/cdn-dp-reg.h              | 409 +++++++++
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c        |   6 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h        |   2 +
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c        |   2 +
 drivers/phy/Kconfig                                |   9 +
 drivers/phy/Makefile                               |   1 +
 drivers/phy/phy-rockchip-typec.c                   | 974 +++++++++++++++++++++
 include/linux/extcon.h                             |  13 +
 16 files changed, 3211 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/display/rockchip/cdn-dp-rockchip.txt
 create mode 100644 Documentation/devicetree/bindings/phy/phy-rockchip-typec.txt
 create mode 100644 drivers/gpu/drm/rockchip/cdn-dp-core.c
 create mode 100644 drivers/gpu/drm/rockchip/cdn-dp-core.h
 create mode 100644 drivers/gpu/drm/rockchip/cdn-dp-reg.c
 create mode 100644 drivers/gpu/drm/rockchip/cdn-dp-reg.h
 create mode 100644 drivers/phy/phy-rockchip-typec.c

-- 
2.6.3

[toc] | [next] | [standalone]


#1441500 — [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChris Zhong <zyw@rock-chips.com>
Date2016-07-12 17:20 +0200
Subject[v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rU7DA-6Gj-39@gated-at.bofh.it>
In reply to#1441498
Add EXTCON_DISP_DP for the Display external connector. For Type-C
connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort
Alt Mode on USB Type-C Standard). The Type-C support both normal and
flipped orientation, so add a property to extcon.

Signe-off-by: Chris Zhong <zyw@rock-chips.com>

Signed-off-by: Chris Zhong <zyw@rock-chips.com>
---

Changes in v5:
- support get property

Changes in v4: None
Changes in v3: None
Changes in v2: None
Changes in v1: None

 drivers/extcon/extcon.c | 28 ++++++++++++++++++++++++++++
 include/linux/extcon.h  | 13 +++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index a1117db..2591b28 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -157,6 +157,11 @@ struct __extcon_info {
 		.id = EXTCON_DISP_VGA,
 		.name = "VGA",
 	},
+	[EXTCON_DISP_DP] = {
+		.type = EXTCON_TYPE_DISP,
+		.id = EXTCON_DISP_DP,
+		.name = "DP",
+	},
 
 	/* Miscellaneous external connector */
 	[EXTCON_DOCK] = {
@@ -270,6 +275,7 @@ static bool is_extcon_property_supported(unsigned int id,
 		switch (prop) {
 		case EXTCON_PROP_USB_ID:
 		case EXTCON_PROP_USB_VBUS:
+		case EXTCON_PROP_TYPEC_POLARITY:
 			return true;
 		default:
 			break;
@@ -286,6 +292,8 @@ static bool is_extcon_property_supported(unsigned int id,
 		}
 	case EXTCON_TYPE_DISP:
 		switch (prop) {
+		case EXTCON_PROP_TYPEC_POLARITY:
+			return true;
 		default:
 			break;
 		}
@@ -547,6 +555,26 @@ int extcon_get_cable_property(struct extcon_dev *edev, unsigned int id,
 				enum extcon_property prop,
 				union extcon_property_value *val)
 {
+	struct extcon_cable *cable;
+	int index;
+
+	if (!edev)
+		return -EINVAL;
+
+	/* Check the property whether is supported or not */
+	if (!is_extcon_property_supported(id, prop))
+		return -EINVAL;
+
+	/* Find the cable index of external connector by using id */
+	index = find_cable_index_by_id(edev, id);
+	if (index < 0)
+		return index;
+
+	/* Store the property value */
+	cable = &edev->cables[index];
+
+	val->intval = cable->propval[prop].intval;
+
 	return 0;
 }
 
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index f6f0a8d..50ef87f 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -77,6 +77,7 @@ enum extcon_type {
 #define EXTCON_DISP_MHL		41	/* Mobile High-Definition Link */
 #define EXTCON_DISP_DVI		42	/* Digital Visual Interface */
 #define EXTCON_DISP_VGA		43	/* Video Graphics Array */
+#define EXTCON_DISP_DP		44	/* DisplayPort */
 
 /* Miscellaneous external connector */
 #define EXTCON_DOCK		60
@@ -108,9 +109,13 @@ enum extcon_property {
 	 * - EXTCON_PROP_USB_USB
 	 * @type:	integer (int value)
 	 * @value:	0 (low) or 1 (high)
+	 * - EXTCON_PROP_TYPEC_POLARITY,
+	 * @type:	integer (int value)
+	 * @value:	0 (normal) or 1 (flip)
 	 */
 	EXTCON_PROP_USB_ID = 0,
 	EXTCON_PROP_USB_VBUS,
+	EXTCON_PROP_TYPEC_POLARITY,
 
 	/* Properties of EXTCON_TYPE_CHG. */
 	/* Properties of EXTCON_TYPE_JACK. */
@@ -225,6 +230,14 @@ extern int extcon_get_cable_state_(struct extcon_dev *edev, unsigned int id);
 extern int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id,
 				   bool cable_state);
 
+extern int extcon_get_cable_property(struct extcon_dev *edev, unsigned int id,
+				     enum extcon_property prop,
+				     union extcon_property_value *val);
+
+extern int extcon_set_cable_property(struct extcon_dev *edev, unsigned int id,
+				     enum extcon_property prop,
+				     union extcon_property_value val);
+
 /*
  * Following APIs are to monitor every action of a notifier.
  * Registrar gets notified for every external port of a connection device.
-- 
2.6.3

[toc] | [prev] | [next] | [standalone]


#1441945 — Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChanwoo Choi <cw00.choi@samsung.com>
Date2016-07-13 03:20 +0200
SubjectRe: [v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rUh0d-4rv-5@gated-at.bofh.it>
In reply to#1441500
Hi Chris,

I'm now developing the extcon property on extcon-test branch.
But, it has not been completed.

On next version, I'll remove the notification about extcon property
and only support the following two functions.
- extcon_set_cable_property()
- extcon_get_cable_property()

Because the number of properties would be risen and the all properties
depend on the specific external connector(e.g., EXTCON_PROP_USB_VBUS
depend on the EXTCON_TYPE_USB type). When the specific external connector
is detached, extcon framework should make the property state as default state.

It may send the too many notification for extcon property.
For example, Assume that EXTCON_TYPE_USB has the over 20 properties,
when EXTCON_USB or EXTCON_USB_HOST is detached, extcon should send
the notification for the over 20 properties and one more notificaiton
for state of external connector.

So, I'll send the RFC patchset without the notification of proerty.

Lastly,
I have a comment on below.

Thanks,
Chanwoo Choi

On 2016년 07월 13일 00:09, Chris Zhong wrote:
> Add EXTCON_DISP_DP for the Display external connector. For Type-C
> connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort
> Alt Mode on USB Type-C Standard). The Type-C support both normal and
> flipped orientation, so add a property to extcon.
> 
> Signe-off-by: Chris Zhong <zyw@rock-chips.com>
> 
> Signed-off-by: Chris Zhong <zyw@rock-chips.com>
> ---
> 
> Changes in v5:
> - support get property
> 
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> Changes in v1: None
> 
>  drivers/extcon/extcon.c | 28 ++++++++++++++++++++++++++++
>  include/linux/extcon.h  | 13 +++++++++++++
>  2 files changed, 41 insertions(+)
> 
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index a1117db..2591b28 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -157,6 +157,11 @@ struct __extcon_info {
>  		.id = EXTCON_DISP_VGA,
>  		.name = "VGA",
>  	},
> +	[EXTCON_DISP_DP] = {
> +		.type = EXTCON_TYPE_DISP,
> +		.id = EXTCON_DISP_DP,
> +		.name = "DP",
> +	},
>  
>  	/* Miscellaneous external connector */
>  	[EXTCON_DOCK] = {
> @@ -270,6 +275,7 @@ static bool is_extcon_property_supported(unsigned int id,
>  		switch (prop) {
>  		case EXTCON_PROP_USB_ID:
>  		case EXTCON_PROP_USB_VBUS:
> +		case EXTCON_PROP_TYPEC_POLARITY:
>  			return true;
>  		default:
>  			break;
> @@ -286,6 +292,8 @@ static bool is_extcon_property_supported(unsigned int id,
>  		}
>  	case EXTCON_TYPE_DISP:
>  		switch (prop) {
> +		case EXTCON_PROP_TYPEC_POLARITY:

Should EXTCON_PROP_TYPEC_POLARITY property add to both EXTCON_TYPE_USB and EXTCON_TYP_DISP?
EXTCON_PROP_TYPEC_POLARITY is the property of USB C-type?

> +			return true;
>  		default:
>  			break;
>  		}
> @@ -547,6 +555,26 @@ int extcon_get_cable_property(struct extcon_dev *edev, unsigned int id,
>  				enum extcon_property prop,
>  				union extcon_property_value *val)
>  {
> +	struct extcon_cable *cable;
> +	int index;
> +
> +	if (!edev)
> +		return -EINVAL;
> +
> +	/* Check the property whether is supported or not */
> +	if (!is_extcon_property_supported(id, prop))
> +		return -EINVAL;
> +
> +	/* Find the cable index of external connector by using id */
> +	index = find_cable_index_by_id(edev, id);
> +	if (index < 0)
> +		return index;
> +
> +	/* Store the property value */
> +	cable = &edev->cables[index];
> +
> +	val->intval = cable->propval[prop].intval;
> +
>  	return 0;
>  }

After I develop it about get_cable_property, I'll send RFC patchset.

>  
> diff --git a/include/linux/extcon.h b/include/linux/extcon.h
> index f6f0a8d..50ef87f 100644
> --- a/include/linux/extcon.h
> +++ b/include/linux/extcon.h
> @@ -77,6 +77,7 @@ enum extcon_type {
>  #define EXTCON_DISP_MHL		41	/* Mobile High-Definition Link */
>  #define EXTCON_DISP_DVI		42	/* Digital Visual Interface */
>  #define EXTCON_DISP_VGA		43	/* Video Graphics Array */
> +#define EXTCON_DISP_DP		44	/* DisplayPort */
>  
>  /* Miscellaneous external connector */
>  #define EXTCON_DOCK		60
> @@ -108,9 +109,13 @@ enum extcon_property {
>  	 * - EXTCON_PROP_USB_USB
>  	 * @type:	integer (int value)
>  	 * @value:	0 (low) or 1 (high)
> +	 * - EXTCON_PROP_TYPEC_POLARITY,
> +	 * @type:	integer (int value)
> +	 * @value:	0 (normal) or 1 (flip)
>  	 */
>  	EXTCON_PROP_USB_ID = 0,
>  	EXTCON_PROP_USB_VBUS,
> +	EXTCON_PROP_TYPEC_POLARITY,
>  
>  	/* Properties of EXTCON_TYPE_CHG. */
>  	/* Properties of EXTCON_TYPE_JACK. */
> @@ -225,6 +230,14 @@ extern int extcon_get_cable_state_(struct extcon_dev *edev, unsigned int id);
>  extern int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id,
>  				   bool cable_state);
>  
> +extern int extcon_get_cable_property(struct extcon_dev *edev, unsigned int id,
> +				     enum extcon_property prop,
> +				     union extcon_property_value *val);
> +
> +extern int extcon_set_cable_property(struct extcon_dev *edev, unsigned int id,
> +				     enum extcon_property prop,
> +				     union extcon_property_value val);
> +

ditto.

Thanks,
Chanwoo Choi

[toc] | [prev] | [next] | [standalone]


#1441952 — Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChris Zhong <zyw@rock-chips.com>
Date2016-07-13 03:50 +0200
SubjectRe: [v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rUhtf-4BR-3@gated-at.bofh.it>
In reply to#1441945
Hi Chanwoo Choi


On 07/13/2016 09:11 AM, Chanwoo Choi wrote:
> Hi Chris,
>
> I'm now developing the extcon property on extcon-test branch.
> But, it has not been completed.
>
> On next version, I'll remove the notification about extcon property
> and only support the following two functions.
> - extcon_set_cable_property()
> - extcon_get_cable_property()
>
> Because the number of properties would be risen and the all properties
> depend on the specific external connector(e.g., EXTCON_PROP_USB_VBUS
> depend on the EXTCON_TYPE_USB type). When the specific external connector
> is detached, extcon framework should make the property state as default state.

Yes, I think getting the notification from cable state is enough, 
actually I am using it like you said.

>
> It may send the too many notification for extcon property.
> For example, Assume that EXTCON_TYPE_USB has the over 20 properties,
> when EXTCON_USB or EXTCON_USB_HOST is detached, extcon should send
> the notification for the over 20 properties and one more notificaiton
> for state of external connector.
>
> So, I'll send the RFC patchset without the notification of proerty.
>
> Lastly,
> I have a comment on below.
>
> Thanks,
> Chanwoo Choi
>
> On 2016년 07월 13일 00:09, Chris Zhong wrote:
>> Add EXTCON_DISP_DP for the Display external connector. For Type-C
>> connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort
>> Alt Mode on USB Type-C Standard). The Type-C support both normal and
>> flipped orientation, so add a property to extcon.
>>
>> Signe-off-by: Chris Zhong <zyw@rock-chips.com>
>>
>> Signed-off-by: Chris Zhong <zyw@rock-chips.com>
>> ---
>>
>> Changes in v5:
>> - support get property
>>
>> Changes in v4: None
>> Changes in v3: None
>> Changes in v2: None
>> Changes in v1: None
>>
>>   drivers/extcon/extcon.c | 28 ++++++++++++++++++++++++++++
>>   include/linux/extcon.h  | 13 +++++++++++++
>>   2 files changed, 41 insertions(+)
>>
>> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
>> index a1117db..2591b28 100644
>> --- a/drivers/extcon/extcon.c
>> +++ b/drivers/extcon/extcon.c
>> @@ -157,6 +157,11 @@ struct __extcon_info {
>>   		.id = EXTCON_DISP_VGA,
>>   		.name = "VGA",
>>   	},
>> +	[EXTCON_DISP_DP] = {
>> +		.type = EXTCON_TYPE_DISP,
>> +		.id = EXTCON_DISP_DP,
>> +		.name = "DP",
>> +	},
>>   
>>   	/* Miscellaneous external connector */
>>   	[EXTCON_DOCK] = {
>> @@ -270,6 +275,7 @@ static bool is_extcon_property_supported(unsigned int id,
>>   		switch (prop) {
>>   		case EXTCON_PROP_USB_ID:
>>   		case EXTCON_PROP_USB_VBUS:
>> +		case EXTCON_PROP_TYPEC_POLARITY:
>>   			return true;
>>   		default:
>>   			break;
>> @@ -286,6 +292,8 @@ static bool is_extcon_property_supported(unsigned int id,
>>   		}
>>   	case EXTCON_TYPE_DISP:
>>   		switch (prop) {
>> +		case EXTCON_PROP_TYPEC_POLARITY:
> Should EXTCON_PROP_TYPEC_POLARITY property add to both EXTCON_TYPE_USB and EXTCON_TYP_DISP?
> EXTCON_PROP_TYPEC_POLARITY is the property of USB C-type?

it is for USB Type-C, But at Display Port alt mode, both EXTCON_USB and 
EXTCON_USB_HOST may be detached. Does it support set the property to a 
detached cable, if so, I think move this case to EXTCON_USB is fine.

Thanks
Chris
>
>> +			return true;
>>   		default:
>>   			break;
>>   		}
>> @@ -547,6 +555,26 @@ int extcon_get_cable_property(struct extcon_dev *edev, unsigned int id,
>>   				enum extcon_property prop,
>>   				union extcon_property_value *val)
>>   {
>> +	struct extcon_cable *cable;
>> +	int index;
>> +
>> +	if (!edev)
>> +		return -EINVAL;
>> +
>> +	/* Check the property whether is supported or not */
>> +	if (!is_extcon_property_supported(id, prop))
>> +		return -EINVAL;
>> +
>> +	/* Find the cable index of external connector by using id */
>> +	index = find_cable_index_by_id(edev, id);
>> +	if (index < 0)
>> +		return index;
>> +
>> +	/* Store the property value */
>> +	cable = &edev->cables[index];
>> +
>> +	val->intval = cable->propval[prop].intval;
>> +
>>   	return 0;
>>   }
> After I develop it about get_cable_property, I'll send RFC patchset.
>
>>   
>> diff --git a/include/linux/extcon.h b/include/linux/extcon.h
>> index f6f0a8d..50ef87f 100644
>> --- a/include/linux/extcon.h
>> +++ b/include/linux/extcon.h
>> @@ -77,6 +77,7 @@ enum extcon_type {
>>   #define EXTCON_DISP_MHL		41	/* Mobile High-Definition Link */
>>   #define EXTCON_DISP_DVI		42	/* Digital Visual Interface */
>>   #define EXTCON_DISP_VGA		43	/* Video Graphics Array */
>> +#define EXTCON_DISP_DP		44	/* DisplayPort */
>>   
>>   /* Miscellaneous external connector */
>>   #define EXTCON_DOCK		60
>> @@ -108,9 +109,13 @@ enum extcon_property {
>>   	 * - EXTCON_PROP_USB_USB
>>   	 * @type:	integer (int value)
>>   	 * @value:	0 (low) or 1 (high)
>> +	 * - EXTCON_PROP_TYPEC_POLARITY,
>> +	 * @type:	integer (int value)
>> +	 * @value:	0 (normal) or 1 (flip)
>>   	 */
>>   	EXTCON_PROP_USB_ID = 0,
>>   	EXTCON_PROP_USB_VBUS,
>> +	EXTCON_PROP_TYPEC_POLARITY,
>>   
>>   	/* Properties of EXTCON_TYPE_CHG. */
>>   	/* Properties of EXTCON_TYPE_JACK. */
>> @@ -225,6 +230,14 @@ extern int extcon_get_cable_state_(struct extcon_dev *edev, unsigned int id);
>>   extern int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id,
>>   				   bool cable_state);
>>   
>> +extern int extcon_get_cable_property(struct extcon_dev *edev, unsigned int id,
>> +				     enum extcon_property prop,
>> +				     union extcon_property_value *val);
>> +
>> +extern int extcon_set_cable_property(struct extcon_dev *edev, unsigned int id,
>> +				     enum extcon_property prop,
>> +				     union extcon_property_value val);
>> +
> ditto.
>
> Thanks,
> Chanwoo Choi
>
>
>

[toc] | [prev] | [next] | [standalone]


#1441959 — Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChanwoo Choi <cw00.choi@samsung.com>
Date2016-07-13 04:10 +0200
SubjectRe: [v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rUhMB-4Y0-15@gated-at.bofh.it>
In reply to#1441952
Hi Chris,

On 2016년 07월 13일 10:39, Chris Zhong wrote:
> Hi Chanwoo Choi
> 
> 
> On 07/13/2016 09:11 AM, Chanwoo Choi wrote:
>> Hi Chris,
>>
>> I'm now developing the extcon property on extcon-test branch.
>> But, it has not been completed.
>>
>> On next version, I'll remove the notification about extcon property
>> and only support the following two functions.
>> - extcon_set_cable_property()
>> - extcon_get_cable_property()
>>
>> Because the number of properties would be risen and the all properties
>> depend on the specific external connector(e.g., EXTCON_PROP_USB_VBUS
>> depend on the EXTCON_TYPE_USB type). When the specific external connector
>> is detached, extcon framework should make the property state as default state.
> 
> Yes, I think getting the notification from cable state is enough, actually I am using it like you said.

OK. 

> 
>>
>> It may send the too many notification for extcon property.
>> For example, Assume that EXTCON_TYPE_USB has the over 20 properties,
>> when EXTCON_USB or EXTCON_USB_HOST is detached, extcon should send
>> the notification for the over 20 properties and one more notificaiton
>> for state of external connector.
>>
>> So, I'll send the RFC patchset without the notification of proerty.
>>
>> Lastly,
>> I have a comment on below.
>>
>> Thanks,
>> Chanwoo Choi
>>
>> On 2016년 07월 13일 00:09, Chris Zhong wrote:
>>> Add EXTCON_DISP_DP for the Display external connector. For Type-C
>>> connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort
>>> Alt Mode on USB Type-C Standard). The Type-C support both normal and
>>> flipped orientation, so add a property to extcon.
>>>
>>> Signe-off-by: Chris Zhong <zyw@rock-chips.com>
>>>
>>> Signed-off-by: Chris Zhong <zyw@rock-chips.com>
>>> ---
>>>
>>> Changes in v5:
>>> - support get property
>>>
>>> Changes in v4: None
>>> Changes in v3: None
>>> Changes in v2: None
>>> Changes in v1: None
>>>
>>>   drivers/extcon/extcon.c | 28 ++++++++++++++++++++++++++++
>>>   include/linux/extcon.h  | 13 +++++++++++++
>>>   2 files changed, 41 insertions(+)
>>>
>>> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
>>> index a1117db..2591b28 100644
>>> --- a/drivers/extcon/extcon.c
>>> +++ b/drivers/extcon/extcon.c
>>> @@ -157,6 +157,11 @@ struct __extcon_info {
>>>           .id = EXTCON_DISP_VGA,
>>>           .name = "VGA",
>>>       },
>>> +    [EXTCON_DISP_DP] = {
>>> +        .type = EXTCON_TYPE_DISP,
>>> +        .id = EXTCON_DISP_DP,
>>> +        .name = "DP",
>>> +    },
>>>         /* Miscellaneous external connector */
>>>       [EXTCON_DOCK] = {
>>> @@ -270,6 +275,7 @@ static bool is_extcon_property_supported(unsigned int id,
>>>           switch (prop) {
>>>           case EXTCON_PROP_USB_ID:
>>>           case EXTCON_PROP_USB_VBUS:
>>> +        case EXTCON_PROP_TYPEC_POLARITY:
>>>               return true;
>>>           default:
>>>               break;
>>> @@ -286,6 +292,8 @@ static bool is_extcon_property_supported(unsigned int id,
>>>           }
>>>       case EXTCON_TYPE_DISP:
>>>           switch (prop) {
>>> +        case EXTCON_PROP_TYPEC_POLARITY:
>> Should EXTCON_PROP_TYPEC_POLARITY property add to both EXTCON_TYPE_USB and EXTCON_TYP_DISP?
>> EXTCON_PROP_TYPEC_POLARITY is the property of USB C-type?
> 
> it is for USB Type-C, But at Display Port alt mode, both EXTCON_USB and EXTCON_USB_HOST may be detached. Does it support set the property to a detached cable, if so, I think move this case to EXTCON_USB is fine.

One external connector can set the state of one more external connector
if the one connector support the various functions.
For example, EXTCON_USB and EXTCON_CHG_USB_SDP
The existing extcon driver[1](e.g., max14577/max77693 etc.) set the state of both EXTCON_USB and EXTCON_CHG_USB_SDP connector at the same time
when usb cable is attached. Because in this case, the usb connector uses as both power supply(EXTCON_CHG_USB_SDP) and data transfer(EXTCON_USB).
[1] https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-next&id=8b45b6a0741678902810d7be95e635c210fbb198

So, DP Alt mode uses the USB Type-C. So, When USB C-type connector is attached for DP Alt mode,
Maybe, you can set the following two state of connector and one property:
- extcon_set_cable_state(edev, [EXTCON_USB or EXTCON_USB_HOST], 1);
- extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
- extcon_set_cable_state(edev, [EXTCON_USB or EXTCON_USB_HOST], EXTCON_PROP_TYPEC_POLARITY, 0 or 1);

Thanks,
Chanwoo Choi

[toc] | [prev] | [next] | [standalone]


#1441976 — Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChris Zhong <zyw@rock-chips.com>
Date2016-07-13 05:00 +0200
SubjectRe: [v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rUiyZ-5mH-7@gated-at.bofh.it>
In reply to#1441959
Hi Chanwoo Choi

On 07/13/2016 10:05 AM, Chanwoo Choi wrote:
> Hi Chris,
>
> On 2016년 07월 13일 10:39, Chris Zhong wrote:
>> Hi Chanwoo Choi
>>
>>
>> On 07/13/2016 09:11 AM, Chanwoo Choi wrote:
>>> Hi Chris,
>>>
>>> I'm now developing the extcon property on extcon-test branch.
>>> But, it has not been completed.
>>>
>>> On next version, I'll remove the notification about extcon property
>>> and only support the following two functions.
>>> - extcon_set_cable_property()
>>> - extcon_get_cable_property()
>>>
>>> Because the number of properties would be risen and the all properties
>>> depend on the specific external connector(e.g., EXTCON_PROP_USB_VBUS
>>> depend on the EXTCON_TYPE_USB type). When the specific external connector
>>> is detached, extcon framework should make the property state as default state.
>> Yes, I think getting the notification from cable state is enough, actually I am using it like you said.
> OK.
>
>>> It may send the too many notification for extcon property.
>>> For example, Assume that EXTCON_TYPE_USB has the over 20 properties,
>>> when EXTCON_USB or EXTCON_USB_HOST is detached, extcon should send
>>> the notification for the over 20 properties and one more notificaiton
>>> for state of external connector.
>>>
>>> So, I'll send the RFC patchset without the notification of proerty.
>>>
>>> Lastly,
>>> I have a comment on below.
>>>
>>> Thanks,
>>> Chanwoo Choi
>>>
>>> On 2016년 07월 13일 00:09, Chris Zhong wrote:
>>>> Add EXTCON_DISP_DP for the Display external connector. For Type-C
>>>> connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort
>>>> Alt Mode on USB Type-C Standard). The Type-C support both normal and
>>>> flipped orientation, so add a property to extcon.
>>>>
>>>> Signe-off-by: Chris Zhong <zyw@rock-chips.com>
>>>>
>>>> Signed-off-by: Chris Zhong <zyw@rock-chips.com>
>>>> ---
>>>>
>>>> Changes in v5:
>>>> - support get property
>>>>
>>>> Changes in v4: None
>>>> Changes in v3: None
>>>> Changes in v2: None
>>>> Changes in v1: None
>>>>
>>>>    drivers/extcon/extcon.c | 28 ++++++++++++++++++++++++++++
>>>>    include/linux/extcon.h  | 13 +++++++++++++
>>>>    2 files changed, 41 insertions(+)
>>>>
>>>> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
>>>> index a1117db..2591b28 100644
>>>> --- a/drivers/extcon/extcon.c
>>>> +++ b/drivers/extcon/extcon.c
>>>> @@ -157,6 +157,11 @@ struct __extcon_info {
>>>>            .id = EXTCON_DISP_VGA,
>>>>            .name = "VGA",
>>>>        },
>>>> +    [EXTCON_DISP_DP] = {
>>>> +        .type = EXTCON_TYPE_DISP,
>>>> +        .id = EXTCON_DISP_DP,
>>>> +        .name = "DP",
>>>> +    },
>>>>          /* Miscellaneous external connector */
>>>>        [EXTCON_DOCK] = {
>>>> @@ -270,6 +275,7 @@ static bool is_extcon_property_supported(unsigned int id,
>>>>            switch (prop) {
>>>>            case EXTCON_PROP_USB_ID:
>>>>            case EXTCON_PROP_USB_VBUS:
>>>> +        case EXTCON_PROP_TYPEC_POLARITY:
>>>>                return true;
>>>>            default:
>>>>                break;
>>>> @@ -286,6 +292,8 @@ static bool is_extcon_property_supported(unsigned int id,
>>>>            }
>>>>        case EXTCON_TYPE_DISP:
>>>>            switch (prop) {
>>>> +        case EXTCON_PROP_TYPEC_POLARITY:
>>> Should EXTCON_PROP_TYPEC_POLARITY property add to both EXTCON_TYPE_USB and EXTCON_TYP_DISP?
>>> EXTCON_PROP_TYPEC_POLARITY is the property of USB C-type?
>> it is for USB Type-C, But at Display Port alt mode, both EXTCON_USB and EXTCON_USB_HOST may be detached. Does it support set the property to a detached cable, if so, I think move this case to EXTCON_USB is fine.
> One external connector can set the state of one more external connector
> if the one connector support the various functions.
> For example, EXTCON_USB and EXTCON_CHG_USB_SDP
> The existing extcon driver[1](e.g., max14577/max77693 etc.) set the state of both EXTCON_USB and EXTCON_CHG_USB_SDP connector at the same time
> when usb cable is attached. Because in this case, the usb connector uses as both power supply(EXTCON_CHG_USB_SDP) and data transfer(EXTCON_USB).
> [1] https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-next&id=8b45b6a0741678902810d7be95e635c210fbb198
>
> So, DP Alt mode uses the USB Type-C. So, When USB C-type connector is attached for DP Alt mode,
> Maybe, you can set the following two state of connector and one property:
> - extcon_set_cable_state(edev, [EXTCON_USB or EXTCON_USB_HOST], 1);
> - extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
> - extcon_set_cable_state(edev, [EXTCON_USB or EXTCON_USB_HOST], EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>
> Thanks,
> Chanwoo Choi

There are 4 modes for Type-C DP alt mode:
1) USB host only  :

extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
extcon_set_cable_state(edev, EXTCON_USB, 0);
extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);

2) USB device only

extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
extcon_set_cable_state(edev, EXTCON_USB, 1);
extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);

3) DP only

extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
extcon_set_cable_state(edev, EXTCON_USB, 0);
extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);

4) USB + DP

extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
extcon_set_cable_state(edev, EXTCON_USB, 0);
extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);


for 3rd mode: DP only, there is only EXTCON_DISP_DP is attached, the 
EXTCON_USB_HOST
and EXTCON_USB are detached, Can I set the property into these 2 
detached cable?
or just call extcon_set_cable_state(edev, EXTCON_DISP_DP, 
EXTCON_PROP_TYPEC_POLARITY, 0 or 1);

>
>
>
>

[toc] | [prev] | [next] | [standalone]


#1442971 — Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChanwoo Choi <cw00.choi@samsung.com>
Date2016-07-14 03:00 +0200
SubjectRe: [v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rUDap-2gp-3@gated-at.bofh.it>
In reply to#1441976
Hi Chris,

On 2016년 07월 13일 11:54, Chris Zhong wrote:
> Hi Chanwoo Choi
> 
> On 07/13/2016 10:05 AM, Chanwoo Choi wrote:
>> Hi Chris,
>>
>> On 2016년 07월 13일 10:39, Chris Zhong wrote:
>>> Hi Chanwoo Choi
>>>
>>>
>>> On 07/13/2016 09:11 AM, Chanwoo Choi wrote:
>>>> Hi Chris,
>>>>
>>>> I'm now developing the extcon property on extcon-test branch.
>>>> But, it has not been completed.
>>>>
>>>> On next version, I'll remove the notification about extcon property
>>>> and only support the following two functions.
>>>> - extcon_set_cable_property()
>>>> - extcon_get_cable_property()
>>>>
>>>> Because the number of properties would be risen and the all properties
>>>> depend on the specific external connector(e.g., EXTCON_PROP_USB_VBUS
>>>> depend on the EXTCON_TYPE_USB type). When the specific external connector
>>>> is detached, extcon framework should make the property state as default state.
>>> Yes, I think getting the notification from cable state is enough, actually I am using it like you said.
>> OK.
>>
>>>> It may send the too many notification for extcon property.
>>>> For example, Assume that EXTCON_TYPE_USB has the over 20 properties,
>>>> when EXTCON_USB or EXTCON_USB_HOST is detached, extcon should send
>>>> the notification for the over 20 properties and one more notificaiton
>>>> for state of external connector.
>>>>
>>>> So, I'll send the RFC patchset without the notification of proerty.
>>>>
>>>> Lastly,
>>>> I have a comment on below.
>>>>
>>>> Thanks,
>>>> Chanwoo Choi
>>>>
>>>> On 2016년 07월 13일 00:09, Chris Zhong wrote:
>>>>> Add EXTCON_DISP_DP for the Display external connector. For Type-C
>>>>> connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort
>>>>> Alt Mode on USB Type-C Standard). The Type-C support both normal and
>>>>> flipped orientation, so add a property to extcon.
>>>>>
>>>>> Signe-off-by: Chris Zhong <zyw@rock-chips.com>
>>>>>
>>>>> Signed-off-by: Chris Zhong <zyw@rock-chips.com>
>>>>> ---
>>>>>
>>>>> Changes in v5:
>>>>> - support get property
>>>>>
>>>>> Changes in v4: None
>>>>> Changes in v3: None
>>>>> Changes in v2: None
>>>>> Changes in v1: None
>>>>>
>>>>>    drivers/extcon/extcon.c | 28 ++++++++++++++++++++++++++++
>>>>>    include/linux/extcon.h  | 13 +++++++++++++
>>>>>    2 files changed, 41 insertions(+)
>>>>>
>>>>> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
>>>>> index a1117db..2591b28 100644
>>>>> --- a/drivers/extcon/extcon.c
>>>>> +++ b/drivers/extcon/extcon.c
>>>>> @@ -157,6 +157,11 @@ struct __extcon_info {
>>>>>            .id = EXTCON_DISP_VGA,
>>>>>            .name = "VGA",
>>>>>        },
>>>>> +    [EXTCON_DISP_DP] = {
>>>>> +        .type = EXTCON_TYPE_DISP,
>>>>> +        .id = EXTCON_DISP_DP,
>>>>> +        .name = "DP",
>>>>> +    },
>>>>>          /* Miscellaneous external connector */
>>>>>        [EXTCON_DOCK] = {
>>>>> @@ -270,6 +275,7 @@ static bool is_extcon_property_supported(unsigned int id,
>>>>>            switch (prop) {
>>>>>            case EXTCON_PROP_USB_ID:
>>>>>            case EXTCON_PROP_USB_VBUS:
>>>>> +        case EXTCON_PROP_TYPEC_POLARITY:
>>>>>                return true;
>>>>>            default:
>>>>>                break;
>>>>> @@ -286,6 +292,8 @@ static bool is_extcon_property_supported(unsigned int id,
>>>>>            }
>>>>>        case EXTCON_TYPE_DISP:
>>>>>            switch (prop) {
>>>>> +        case EXTCON_PROP_TYPEC_POLARITY:
>>>> Should EXTCON_PROP_TYPEC_POLARITY property add to both EXTCON_TYPE_USB and EXTCON_TYP_DISP?
>>>> EXTCON_PROP_TYPEC_POLARITY is the property of USB C-type?
>>> it is for USB Type-C, But at Display Port alt mode, both EXTCON_USB and EXTCON_USB_HOST may be detached. Does it support set the property to a detached cable, if so, I think move this case to EXTCON_USB is fine.
>> One external connector can set the state of one more external connector
>> if the one connector support the various functions.
>> For example, EXTCON_USB and EXTCON_CHG_USB_SDP
>> The existing extcon driver[1](e.g., max14577/max77693 etc.) set the state of both EXTCON_USB and EXTCON_CHG_USB_SDP connector at the same time
>> when usb cable is attached. Because in this case, the usb connector uses as both power supply(EXTCON_CHG_USB_SDP) and data transfer(EXTCON_USB).
>> [1] https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-next&id=8b45b6a0741678902810d7be95e635c210fbb198
>>
>> So, DP Alt mode uses the USB Type-C. So, When USB C-type connector is attached for DP Alt mode,
>> Maybe, you can set the following two state of connector and one property:
>> - extcon_set_cable_state(edev, [EXTCON_USB or EXTCON_USB_HOST], 1);
>> - extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>> - extcon_set_cable_state(edev, [EXTCON_USB or EXTCON_USB_HOST], EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>>
>> Thanks,
>> Chanwoo Choi
> 
> There are 4 modes for Type-C DP alt mode:
> 1) USB host only  :
> 
> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
> extcon_set_cable_state(edev, EXTCON_USB, 0);
> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
> 
> 2) USB device only
> 
> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
> extcon_set_cable_state(edev, EXTCON_USB, 1);
> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
> 
> 3) DP only
> 
> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
> extcon_set_cable_state(edev, EXTCON_USB, 0);
> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
> 
> 4) USB + DP
> 
> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
> extcon_set_cable_state(edev, EXTCON_USB, 0);
> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
> 
> 
> for 3rd mode: DP only, there is only EXTCON_DISP_DP is attached, the EXTCON_USB_HOST
> and EXTCON_USB are detached, Can I set the property into these 2 detached cable?
> or just call extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);

I'm thinking to solve this issue. In result, we can add one more type to specific connector.
For EXTCON_DISP_DP, we can add the two type as following. And EXTCON_PROP_TYPEC_POLARITY property
should be added to EXTCON_TYPE_USB.

+	[EXTCON_DISP_DP] = {
+		.type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
+		.id = EXTCON_DISP_DP,
+		.name = "DP",
+	},

So, as you mentioned, EXTCON_DISP_DP can set the EXTCON_PROP_TYPEC_POLARITY property as following:
- extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);

I'll again developing the extcon property.

Thanks,
Chanwoo Choi

[toc] | [prev] | [next] | [standalone]


#1442973 — Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChris Zhong <zyw@rock-chips.com>
Date2016-07-14 03:10 +0200
SubjectRe: [v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rUDk6-2z3-3@gated-at.bofh.it>
In reply to#1442971
Hi Chanwoo Choi

On 07/14/2016 08:49 AM, Chanwoo Choi wrote:
> Hi Chris,
>
> On 2016년 07월 13일 11:54, Chris Zhong wrote:
>> Hi Chanwoo Choi
>>
>> On 07/13/2016 10:05 AM, Chanwoo Choi wrote:
>>> Hi Chris,
>>>
>>> On 2016년 07월 13일 10:39, Chris Zhong wrote:
>>>> Hi Chanwoo Choi
>>>>
>>>>
>>>> On 07/13/2016 09:11 AM, Chanwoo Choi wrote:
>>>>> Hi Chris,
>>>>>
>>>>> I'm now developing the extcon property on extcon-test branch.
>>>>> But, it has not been completed.
>>>>>
>>>>> On next version, I'll remove the notification about extcon property
>>>>> and only support the following two functions.
>>>>> - extcon_set_cable_property()
>>>>> - extcon_get_cable_property()
>>>>>
>>>>> Because the number of properties would be risen and the all properties
>>>>> depend on the specific external connector(e.g., EXTCON_PROP_USB_VBUS
>>>>> depend on the EXTCON_TYPE_USB type). When the specific external connector
>>>>> is detached, extcon framework should make the property state as default state.
>>>> Yes, I think getting the notification from cable state is enough, actually I am using it like you said.
>>> OK.
>>>
>>>>> It may send the too many notification for extcon property.
>>>>> For example, Assume that EXTCON_TYPE_USB has the over 20 properties,
>>>>> when EXTCON_USB or EXTCON_USB_HOST is detached, extcon should send
>>>>> the notification for the over 20 properties and one more notificaiton
>>>>> for state of external connector.
>>>>>
>>>>> So, I'll send the RFC patchset without the notification of proerty.
>>>>>
>>>>> Lastly,
>>>>> I have a comment on below.
>>>>>
>>>>> Thanks,
>>>>> Chanwoo Choi
>>>>>
>>>>> On 2016년 07월 13일 00:09, Chris Zhong wrote:
>>>>>> Add EXTCON_DISP_DP for the Display external connector. For Type-C
>>>>>> connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort
>>>>>> Alt Mode on USB Type-C Standard). The Type-C support both normal and
>>>>>> flipped orientation, so add a property to extcon.
>>>>>>
>>>>>> Signe-off-by: Chris Zhong <zyw@rock-chips.com>
>>>>>>
>>>>>> Signed-off-by: Chris Zhong <zyw@rock-chips.com>
>>>>>> ---
>>>>>>
>>>>>> Changes in v5:
>>>>>> - support get property
>>>>>>
>>>>>> Changes in v4: None
>>>>>> Changes in v3: None
>>>>>> Changes in v2: None
>>>>>> Changes in v1: None
>>>>>>
>>>>>>     drivers/extcon/extcon.c | 28 ++++++++++++++++++++++++++++
>>>>>>     include/linux/extcon.h  | 13 +++++++++++++
>>>>>>     2 files changed, 41 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
>>>>>> index a1117db..2591b28 100644
>>>>>> --- a/drivers/extcon/extcon.c
>>>>>> +++ b/drivers/extcon/extcon.c
>>>>>> @@ -157,6 +157,11 @@ struct __extcon_info {
>>>>>>             .id = EXTCON_DISP_VGA,
>>>>>>             .name = "VGA",
>>>>>>         },
>>>>>> +    [EXTCON_DISP_DP] = {
>>>>>> +        .type = EXTCON_TYPE_DISP,
>>>>>> +        .id = EXTCON_DISP_DP,
>>>>>> +        .name = "DP",
>>>>>> +    },
>>>>>>           /* Miscellaneous external connector */
>>>>>>         [EXTCON_DOCK] = {
>>>>>> @@ -270,6 +275,7 @@ static bool is_extcon_property_supported(unsigned int id,
>>>>>>             switch (prop) {
>>>>>>             case EXTCON_PROP_USB_ID:
>>>>>>             case EXTCON_PROP_USB_VBUS:
>>>>>> +        case EXTCON_PROP_TYPEC_POLARITY:
>>>>>>                 return true;
>>>>>>             default:
>>>>>>                 break;
>>>>>> @@ -286,6 +292,8 @@ static bool is_extcon_property_supported(unsigned int id,
>>>>>>             }
>>>>>>         case EXTCON_TYPE_DISP:
>>>>>>             switch (prop) {
>>>>>> +        case EXTCON_PROP_TYPEC_POLARITY:
>>>>> Should EXTCON_PROP_TYPEC_POLARITY property add to both EXTCON_TYPE_USB and EXTCON_TYP_DISP?
>>>>> EXTCON_PROP_TYPEC_POLARITY is the property of USB C-type?
>>>> it is for USB Type-C, But at Display Port alt mode, both EXTCON_USB and EXTCON_USB_HOST may be detached. Does it support set the property to a detached cable, if so, I think move this case to EXTCON_USB is fine.
>>> One external connector can set the state of one more external connector
>>> if the one connector support the various functions.
>>> For example, EXTCON_USB and EXTCON_CHG_USB_SDP
>>> The existing extcon driver[1](e.g., max14577/max77693 etc.) set the state of both EXTCON_USB and EXTCON_CHG_USB_SDP connector at the same time
>>> when usb cable is attached. Because in this case, the usb connector uses as both power supply(EXTCON_CHG_USB_SDP) and data transfer(EXTCON_USB).
>>> [1] https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-next&id=8b45b6a0741678902810d7be95e635c210fbb198
>>>
>>> So, DP Alt mode uses the USB Type-C. So, When USB C-type connector is attached for DP Alt mode,
>>> Maybe, you can set the following two state of connector and one property:
>>> - extcon_set_cable_state(edev, [EXTCON_USB or EXTCON_USB_HOST], 1);
>>> - extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>>> - extcon_set_cable_state(edev, [EXTCON_USB or EXTCON_USB_HOST], EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>>>
>>> Thanks,
>>> Chanwoo Choi
>> There are 4 modes for Type-C DP alt mode:
>> 1) USB host only  :
>>
>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
>>
>> 2) USB device only
>>
>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
>> extcon_set_cable_state(edev, EXTCON_USB, 1);
>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
>>
>> 3) DP only
>>
>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>>
>> 4) USB + DP
>>
>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>>
>>
>> for 3rd mode: DP only, there is only EXTCON_DISP_DP is attached, the EXTCON_USB_HOST
>> and EXTCON_USB are detached, Can I set the property into these 2 detached cable?
>> or just call extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
> I'm thinking to solve this issue. In result, we can add one more type to specific connector.
> For EXTCON_DISP_DP, we can add the two type as following. And EXTCON_PROP_TYPEC_POLARITY property
> should be added to EXTCON_TYPE_USB.
>
> +	[EXTCON_DISP_DP] = {
> +		.type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
> +		.id = EXTCON_DISP_DP,
> +		.name = "DP",
> +	},
>
> So, as you mentioned, EXTCON_DISP_DP can set the EXTCON_PROP_TYPEC_POLARITY property as following:
> - extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>
> I'll again developing the extcon property.
>
> Thanks,
> Chanwoo Choi
>
Nice idea, But I am thinking about is it compatible with real 
DisplayPort without Type-C.
Maybe we should add a new cable: EXTCON_DISP_DP_ALT

+	[EXTCON_DISP_DP] = {
+		.type = EXTCON_TYPE_DISP,
+		.id = EXTCON_DISP_DP,
+		.name = "DP",
+	},

+	[EXTCON_DISP_DP_ALT] = {
+		.type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
+		.id = EXTCON_DISP_DP,
+		.name = "DP ALT",
+	},



>
>

[toc] | [prev] | [next] | [standalone]


#1442975 — Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChanwoo Choi <cw00.choi@samsung.com>
Date2016-07-14 03:20 +0200
SubjectRe: [v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rUDtL-2CC-1@gated-at.bofh.it>
In reply to#1442973
Hi Chris,

[snip]

>>>> Thanks,
>>>> Chanwoo Choi
>>> There are 4 modes for Type-C DP alt mode:
>>> 1) USB host only  :
>>>
>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
>>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
>>>
>>> 2) USB device only
>>>
>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
>>> extcon_set_cable_state(edev, EXTCON_USB, 1);
>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
>>>
>>> 3) DP only
>>>
>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
>>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>>>
>>> 4) USB + DP
>>>
>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
>>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>>>
>>>
>>> for 3rd mode: DP only, there is only EXTCON_DISP_DP is attached, the EXTCON_USB_HOST
>>> and EXTCON_USB are detached, Can I set the property into these 2 detached cable?
>>> or just call extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>> I'm thinking to solve this issue. In result, we can add one more type to specific connector.
>> For EXTCON_DISP_DP, we can add the two type as following. And EXTCON_PROP_TYPEC_POLARITY property
>> should be added to EXTCON_TYPE_USB.
>>
>> +    [EXTCON_DISP_DP] = {
>> +        .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
>> +        .id = EXTCON_DISP_DP,
>> +        .name = "DP",
>> +    },
>>
>> So, as you mentioned, EXTCON_DISP_DP can set the EXTCON_PROP_TYPEC_POLARITY property as following:
>> - extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>>
>> I'll again developing the extcon property.
>>
>> Thanks,
>> Chanwoo Choi
>>
> Nice idea, But I am thinking about is it compatible with real DisplayPort without Type-C.
> Maybe we should add a new cable: EXTCON_DISP_DP_ALT
> 
> +    [EXTCON_DISP_DP] = {
> +        .type = EXTCON_TYPE_DISP,
> +        .id = EXTCON_DISP_DP,
> +        .name = "DP",
> +    },
> 
> +    [EXTCON_DISP_DP_ALT] = {
> +        .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
> +        .id = EXTCON_DISP_DP,
> +        .name = "DP ALT",
> +    },

EXTCON_DISP_DP_ALT means EXTCON_DISP_DP connector with EXTCON_PROP_TYPEC_POLARITY property.
So, we can explain the DP alternative mode without EXTCON_DISP_DP_ALT.

I'm wondering to add the new EXTCON_DISP_DP_ALT connector
because alternative mode was defined as mode instead of new h/w connector type.

Thanks,
Chanwoo Choi

[toc] | [prev] | [next] | [standalone]


#1442998 — Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChris Zhong <zyw@rock-chips.com>
Date2016-07-14 04:10 +0200
SubjectRe: [v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rUEg9-3ar-15@gated-at.bofh.it>
In reply to#1442975
Hi Chanwoo Choi

On 07/14/2016 09:15 AM, Chanwoo Choi wrote:
> Hi Chris,
>
> [snip]
>
>>>>> Thanks,
>>>>> Chanwoo Choi
>>>> There are 4 modes for Type-C DP alt mode:
>>>> 1) USB host only  :
>>>>
>>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
>>>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
>>>>
>>>> 2) USB device only
>>>>
>>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
>>>> extcon_set_cable_state(edev, EXTCON_USB, 1);
>>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
>>>>
>>>> 3) DP only
>>>>
>>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
>>>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>>>>
>>>> 4) USB + DP
>>>>
>>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
>>>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>>>>
>>>>
>>>> for 3rd mode: DP only, there is only EXTCON_DISP_DP is attached, the EXTCON_USB_HOST
>>>> and EXTCON_USB are detached, Can I set the property into these 2 detached cable?
>>>> or just call extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>>> I'm thinking to solve this issue. In result, we can add one more type to specific connector.
>>> For EXTCON_DISP_DP, we can add the two type as following. And EXTCON_PROP_TYPEC_POLARITY property
>>> should be added to EXTCON_TYPE_USB.
>>>
>>> +    [EXTCON_DISP_DP] = {
>>> +        .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
>>> +        .id = EXTCON_DISP_DP,
>>> +        .name = "DP",
>>> +    },
>>>
>>> So, as you mentioned, EXTCON_DISP_DP can set the EXTCON_PROP_TYPEC_POLARITY property as following:
>>> - extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>>>
>>> I'll again developing the extcon property.
>>>
>>> Thanks,
>>> Chanwoo Choi
>>>
>> Nice idea, But I am thinking about is it compatible with real DisplayPort without Type-C.
>> Maybe we should add a new cable: EXTCON_DISP_DP_ALT
>>
>> +    [EXTCON_DISP_DP] = {
>> +        .type = EXTCON_TYPE_DISP,
>> +        .id = EXTCON_DISP_DP,
>> +        .name = "DP",
>> +    },
>>
>> +    [EXTCON_DISP_DP_ALT] = {
>> +        .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
>> +        .id = EXTCON_DISP_DP,
>> +        .name = "DP ALT",
>> +    },
> EXTCON_DISP_DP_ALT means EXTCON_DISP_DP connector with EXTCON_PROP_TYPEC_POLARITY property.
> So, we can explain the DP alternative mode without EXTCON_DISP_DP_ALT.
>
> I'm wondering to add the new EXTCON_DISP_DP_ALT connector
> because alternative mode was defined as mode instead of new h/w connector type.
>
> Thanks,
> Chanwoo Choi
>
>
Okay, so I think some comment for EXTCON_DISP_DP is necessary and enough.
>
>

[toc] | [prev] | [next] | [standalone]


#1443005 — Re: [v5 PATCH 1/5] extcon: Add Type-C and DP support

FromChanwoo Choi <cw00.choi@samsung.com>
Date2016-07-14 04:20 +0200
SubjectRe: [v5 PATCH 1/5] extcon: Add Type-C and DP support
Message-ID<rUEpQ-3ke-7@gated-at.bofh.it>
In reply to#1442998
Hi Chris,

On 2016년 07월 14일 11:07, Chris Zhong wrote:
> Hi Chanwoo Choi
> 
> On 07/14/2016 09:15 AM, Chanwoo Choi wrote:
>> Hi Chris,
>>
>> [snip]
>>
>>>>>> Thanks,
>>>>>> Chanwoo Choi
>>>>> There are 4 modes for Type-C DP alt mode:
>>>>> 1) USB host only  :
>>>>>
>>>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
>>>>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>>>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
>>>>>
>>>>> 2) USB device only
>>>>>
>>>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
>>>>> extcon_set_cable_state(edev, EXTCON_USB, 1);
>>>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 0);
>>>>>
>>>>> 3) DP only
>>>>>
>>>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 0);
>>>>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>>>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>>>>>
>>>>> 4) USB + DP
>>>>>
>>>>> extcon_set_cable_state(edev, EXTCON_USB_HOST, 1);
>>>>> extcon_set_cable_state(edev, EXTCON_USB, 0);
>>>>> extcon_set_cable_state(edev, EXTCON_DISP_DP, 1);
>>>>>
>>>>>
>>>>> for 3rd mode: DP only, there is only EXTCON_DISP_DP is attached, the EXTCON_USB_HOST
>>>>> and EXTCON_USB are detached, Can I set the property into these 2 detached cable?
>>>>> or just call extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>>>> I'm thinking to solve this issue. In result, we can add one more type to specific connector.
>>>> For EXTCON_DISP_DP, we can add the two type as following. And EXTCON_PROP_TYPEC_POLARITY property
>>>> should be added to EXTCON_TYPE_USB.
>>>>
>>>> +    [EXTCON_DISP_DP] = {
>>>> +        .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
>>>> +        .id = EXTCON_DISP_DP,
>>>> +        .name = "DP",
>>>> +    },
>>>>
>>>> So, as you mentioned, EXTCON_DISP_DP can set the EXTCON_PROP_TYPEC_POLARITY property as following:
>>>> - extcon_set_cable_state(edev, EXTCON_DISP_DP, EXTCON_PROP_TYPEC_POLARITY, 0 or 1);
>>>>
>>>> I'll again developing the extcon property.
>>>>
>>>> Thanks,
>>>> Chanwoo Choi
>>>>
>>> Nice idea, But I am thinking about is it compatible with real DisplayPort without Type-C.
>>> Maybe we should add a new cable: EXTCON_DISP_DP_ALT
>>>
>>> +    [EXTCON_DISP_DP] = {
>>> +        .type = EXTCON_TYPE_DISP,
>>> +        .id = EXTCON_DISP_DP,
>>> +        .name = "DP",
>>> +    },
>>>
>>> +    [EXTCON_DISP_DP_ALT] = {
>>> +        .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
>>> +        .id = EXTCON_DISP_DP,
>>> +        .name = "DP ALT",
>>> +    },
>> EXTCON_DISP_DP_ALT means EXTCON_DISP_DP connector with EXTCON_PROP_TYPEC_POLARITY property.
>> So, we can explain the DP alternative mode without EXTCON_DISP_DP_ALT.
>>
>> I'm wondering to add the new EXTCON_DISP_DP_ALT connector
>> because alternative mode was defined as mode instead of new h/w connector type.
>>
>> Thanks,
>> Chanwoo Choi
>>
>>
> Okay, so I think some comment for EXTCON_DISP_DP is necessary and enough.

Okay. I'll do that

Thanks,
Chanwoo Choi

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web