Re: [PATCH 2/2] extcon: Add the support of EXTCON_CHG_USB when SDP port is attached or detached

From: Chanwoo Choi
Date: Tue Oct 06 2015 - 08:12:49 EST


Roger,

On 2015ë 10ì 06ì 20:49, Roger Quadros wrote:
> Hi,
>
> On 06/10/15 14:21, Chanwoo Choi wrote:
>> The SDP (Standard Downstream Port) is one of various USB Charging ports. The SDP
>> supports both the data transmission and the charging through USB connector at
>> the same time. So, the EXTCON framework defines two connector type for USB SDP
>> connector as following:
>> - EXTCON_USB means the USB cable for data transmission.
>> - EXTCON_CHG_USB means the USB charger cable for battery charging.
>>
>> This patch add the support of EXTCON_CHG_USB when USB SDP is attached or
>> detached.
>
> I didn't understand why this change is needed. SDP, EXTCON_USB and EXTCON_CHG_USB
> are the same thing. no?

As you knew, SDP support both data transmission and charging
through one port at the same time. Also, On patch1 of this patch-set,
I add the prefix to clarify both attribute and meaning of external connector as following:
- EXTCON_CHG_* mean the charger connector.

So, there are three possible naming approach for USB SDP.

Approach 1.
- EXTCON_USB /* SDP for both data transmission and charging */

Approach 2.
- EXTCON_USB /* SDP for data transmission */
- EXTCON_CHG_USB /* SDP for charging */

Approach 3.
- EXTCON_CHG_USB /* SDP for both data transmission and charging */

It is not fixed about name. I want to discuss what is proper name for USB SDP.

Thanks,
Chanwoo Choi

>
> cheers,
> -roger
>
>>
>> Signed-off-by: Chanwoo Choi <cw00.choi@xxxxxxxxxxx>
>> ---
>> drivers/extcon/extcon-max14577.c | 2 ++
>> drivers/extcon/extcon-max77693.c | 11 ++++++++++-
>> drivers/extcon/extcon-max77843.c | 2 ++
>> drivers/extcon/extcon-max8997.c | 2 ++
>> drivers/extcon/extcon-palmas.c | 3 +++
>> drivers/extcon/extcon-rt8973a.c | 3 +++
>> drivers/extcon/extcon-sm5502.c | 3 +++
>> drivers/extcon/extcon-usb-gpio.c | 3 +++
>> 8 files changed, 28 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
>> index 15c2dcc73fc6..f262dad10560 100644
>> --- a/drivers/extcon/extcon-max14577.c
>> +++ b/drivers/extcon/extcon-max14577.c
>> @@ -150,6 +150,7 @@ enum max14577_muic_acc_type {
>>
>> static const unsigned int max14577_extcon_cable[] = {
>> EXTCON_USB,
>> + EXTCON_CHG_USB,
>> EXTCON_CHG_USB_DCP,
>> EXTCON_CHG_USB_DCP_FAST,
>> EXTCON_CHG_USB_DCP_SLOW,
>> @@ -454,6 +455,7 @@ static int max14577_muic_chg_handler(struct max14577_muic_info *info)
>> return ret;
>>
>> extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB, attached);
>> break;
>> case MAX14577_CHARGER_TYPE_DEDICATED_CHG:
>> extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_DCP,
>> diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
>> index 95c707b1fcee..ee63718de787 100644
>> --- a/drivers/extcon/extcon-max77693.c
>> +++ b/drivers/extcon/extcon-max77693.c
>> @@ -204,6 +204,7 @@ enum max77693_muic_acc_type {
>> static const unsigned int max77693_extcon_cable[] = {
>> EXTCON_USB,
>> EXTCON_USB_HOST,
>> + EXTCON_CHG_USB,
>> EXTCON_CHG_USB_DCP,
>> EXTCON_CHG_USB_DCP_FAST,
>> EXTCON_CHG_USB_DCP_SLOW,
>> @@ -512,8 +513,11 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
>> break;
>> case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */
>> dock_id = EXTCON_DOCK;
>> - if (!attached)
>> + if (!attached) {
>> extcon_set_cable_state_(info->edev, EXTCON_USB, false);
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB,
>> + false);
>> + }
>> break;
>> default:
>> dev_err(info->dev, "failed to detect %s dock device\n",
>> @@ -601,6 +605,7 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info)
>> if (ret < 0)
>> return ret;
>> extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB, attached);
>> break;
>> case MAX77693_MUIC_GND_MHL:
>> case MAX77693_MUIC_GND_MHL_VB:
>> @@ -830,6 +835,8 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info)
>> */
>> extcon_set_cable_state_(info->edev, EXTCON_USB,
>> attached);
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB,
>> + attached);
>>
>> if (!cable_attached)
>> extcon_set_cable_state_(info->edev, EXTCON_DOCK,
>> @@ -899,6 +906,8 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info)
>>
>> extcon_set_cable_state_(info->edev, EXTCON_USB,
>> attached);
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB,
>> + attached);
>> break;
>> case MAX77693_CHARGER_TYPE_DEDICATED_CHG:
>> /* Only TA cable */
>> diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
>> index 97aebe5d67a6..5bfd4a5ec9c4 100644
>> --- a/drivers/extcon/extcon-max77843.c
>> +++ b/drivers/extcon/extcon-max77843.c
>> @@ -122,6 +122,7 @@ enum max77843_muic_charger_type {
>> static const unsigned int max77843_extcon_cable[] = {
>> EXTCON_USB,
>> EXTCON_USB_HOST,
>> + EXTCON_CHG_USB,
>> EXTCON_CHG_USB_DCP,
>> EXTCON_CHG_USB_CDP,
>> EXTCON_CHG_USB_DCP_FAST,
>> @@ -486,6 +487,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
>> return ret;
>>
>> extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB, attached);
>> break;
>> case MAX77843_MUIC_CHG_DOWNSTREAM:
>> ret = max77843_muic_set_path(info,
>> diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
>> index 8dbec5febdb6..3e8c6ab546b6 100644
>> --- a/drivers/extcon/extcon-max8997.c
>> +++ b/drivers/extcon/extcon-max8997.c
>> @@ -148,6 +148,7 @@ struct max8997_muic_info {
>> static const unsigned int max8997_extcon_cable[] = {
>> EXTCON_USB,
>> EXTCON_USB_HOST,
>> + EXTCON_CHG_USB,
>> EXTCON_CHG_USB_DCP,
>> EXTCON_CHG_USB_DCP_FAST,
>> EXTCON_CHG_USB_DCP_SLOW,
>> @@ -334,6 +335,7 @@ static int max8997_muic_handle_usb(struct max8997_muic_info *info,
>> break;
>> case MAX8997_USB_DEVICE:
>> extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB, attached);
>> break;
>> default:
>> dev_err(info->dev, "failed to detect %s usb cable\n",
>> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
>> index 93c30a885740..a1e984ff4398 100644
>> --- a/drivers/extcon/extcon-palmas.c
>> +++ b/drivers/extcon/extcon-palmas.c
>> @@ -37,6 +37,7 @@
>> static const unsigned int palmas_extcon_cable[] = {
>> EXTCON_USB,
>> EXTCON_USB_HOST,
>> + EXTCON_CHG_USB,
>> EXTCON_NONE,
>> };
>>
>> @@ -62,6 +63,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
>> if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) {
>> palmas_usb->linkstat = PALMAS_USB_STATE_VBUS;
>> extcon_set_cable_state_(edev, EXTCON_USB, true);
>> + extcon_set_cable_state_(edev, EXTCON_CHG_USB, true);
>> dev_info(palmas_usb->dev, "USB cable is attached\n");
>> } else {
>> dev_dbg(palmas_usb->dev,
>> @@ -71,6 +73,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
>> if (palmas_usb->linkstat == PALMAS_USB_STATE_VBUS) {
>> palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
>> extcon_set_cable_state_(edev, EXTCON_USB, false);
>> + extcon_set_cable_state_(edev, EXTCON_CHG_USB, false);
>> dev_info(palmas_usb->dev, "USB cable is detached\n");
>> } else {
>> dev_dbg(palmas_usb->dev,
>> diff --git a/drivers/extcon/extcon-rt8973a.c b/drivers/extcon/extcon-rt8973a.c
>> index 36bf1d63791c..64c7d8a90a11 100644
>> --- a/drivers/extcon/extcon-rt8973a.c
>> +++ b/drivers/extcon/extcon-rt8973a.c
>> @@ -93,6 +93,7 @@ static struct reg_data rt8973a_reg_data[] = {
>> static const unsigned int rt8973a_extcon_cable[] = {
>> EXTCON_USB,
>> EXTCON_USB_HOST,
>> + EXTCON_CHG_USB,
>> EXTCON_CHG_USB_DCP,
>> EXTCON_JIG,
>> EXTCON_NONE,
>> @@ -398,6 +399,8 @@ static int rt8973a_muic_cable_handler(struct rt8973a_muic_info *info,
>>
>> /* Change the state of external accessory */
>> extcon_set_cable_state_(info->edev, id, attached);
>> + if (id == EXTCON_USB)
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB, attached);
>>
>> return 0;
>> }
>> diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c
>> index 7aac3cc7efd7..24031759d306 100644
>> --- a/drivers/extcon/extcon-sm5502.c
>> +++ b/drivers/extcon/extcon-sm5502.c
>> @@ -95,6 +95,7 @@ static struct reg_data sm5502_reg_data[] = {
>> static const unsigned int sm5502_extcon_cable[] = {
>> EXTCON_USB,
>> EXTCON_USB_HOST,
>> + EXTCON_CHG_USB,
>> EXTCON_CHG_USB_DCP,
>> EXTCON_NONE,
>> };
>> @@ -411,6 +412,8 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info,
>>
>> /* Change the state of external accessory */
>> extcon_set_cable_state_(info->edev, id, attached);
>> + if (id == EXTCON_USB)
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB, attached);
>>
>> return 0;
>> }
>> diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
>> index 2b2fecffb1ad..ae8e3df0b5a6 100644
>> --- a/drivers/extcon/extcon-usb-gpio.c
>> +++ b/drivers/extcon/extcon-usb-gpio.c
>> @@ -43,6 +43,7 @@ struct usb_extcon_info {
>> static const unsigned int usb_extcon_cable[] = {
>> EXTCON_USB,
>> EXTCON_USB_HOST,
>> + EXTCON_CHG_USB,
>> EXTCON_NONE,
>> };
>>
>> @@ -63,12 +64,14 @@ static void usb_extcon_detect_cable(struct work_struct *work)
>> */
>> extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, false);
>> extcon_set_cable_state_(info->edev, EXTCON_USB, true);
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB, true);
>> } else {
>> /*
>> * ID = 0 means USB HOST cable attached.
>> * As we don't have event for USB peripheral cable detached,
>> * we simulate USB peripheral detach here.
>> */
>> + extcon_set_cable_state_(info->edev, EXTCON_CHG_USB, false);
>> extcon_set_cable_state_(info->edev, EXTCON_USB, false);
>> extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, true);
>> }
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/