All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@samsung.com>
To: MyungJoo Ham <myungjoo.ham@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Jaewon Kim <jaewon02.kim@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	linux-kernel@vger.kernel.org, Andi Shyti <andi.shyti@samsung.com>,
	Andi Shyti <andi@etezian.org>
Subject: [PATCH 2/2] extcon: max77843: support USB accessories as external USB hosts
Date: Wed, 29 Mar 2017 20:54:53 +0900	[thread overview]
Message-ID: <20170329115453.4268-3-andi.shyti@samsung.com> (raw)
In-Reply-To: <20170329115453.4268-1-andi.shyti@samsung.com>

The ADC state defines the resistance that a USB device has in
order to distinguish between devices.

The external accessories (like the Gear VR) are defined as:

MAX77843_MUIC_ADC_RESERVED_ACC_1
MAX77843_MUIC_ADC_RESERVED_ACC_2
MAX77843_MUIC_ADC_RESERVED_ACC_3
MAX77843_MUIC_ADC_RESERVED_ACC_4
MAX77843_MUIC_ADC_RESERVED_ACC_5

and they should be set as such in the extcon driver.

Do not ignore interrupts generated by external accessories by
handling cables of the type from any of the above.

Do not handle any charging related action. This can be
misleading as also external devices might have some power and in
such cases the MUIC might consider them as power providers. In
this case check the value of the adc and if it corresponds to
one or the MAX77843_MUIC_ADC_RESERVED_ACC_*, return a no-action
value (MAX77843_MUIC_CHG_NONE).

Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
 drivers/extcon/extcon-max77843.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
index fcdabc4b4025..00795fe9ab60 100644
--- a/drivers/extcon/extcon-max77843.c
+++ b/drivers/extcon/extcon-max77843.c
@@ -271,6 +271,13 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info,
 		} else {
 			*attached = true;
 			switch (adc) {
+			case MAX77843_MUIC_ADC_RESERVED_ACC_1:
+			case MAX77843_MUIC_ADC_RESERVED_ACC_2:
+			case MAX77843_MUIC_ADC_RESERVED_ACC_3:
+			case MAX77843_MUIC_ADC_RESERVED_ACC_4:
+			case MAX77843_MUIC_ADC_RESERVED_ACC_5:
+				info->prev_chg_type = MAX77843_MUIC_CHG_NONE;
+				break;
 			case MAX77843_MUIC_ADC_GROUND:
 				info->prev_chg_type = MAX77843_MUIC_CHG_GND;
 				break;
@@ -403,6 +410,11 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info)
 
 	switch (cable_type) {
 	case MAX77843_MUIC_ADC_GROUND:
+	case MAX77843_MUIC_ADC_RESERVED_ACC_1:
+	case MAX77843_MUIC_ADC_RESERVED_ACC_2:
+	case MAX77843_MUIC_ADC_RESERVED_ACC_3:
+	case MAX77843_MUIC_ADC_RESERVED_ACC_4:
+	case MAX77843_MUIC_ADC_RESERVED_ACC_5:
 		ret = max77843_muic_adc_gnd_handler(info);
 		if (ret < 0)
 			return ret;
@@ -427,11 +439,6 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info)
 	case MAX77843_MUIC_ADC_REMOTE_S10_BUTTON:
 	case MAX77843_MUIC_ADC_REMOTE_S11_BUTTON:
 	case MAX77843_MUIC_ADC_REMOTE_S12_BUTTON:
-	case MAX77843_MUIC_ADC_RESERVED_ACC_1:
-	case MAX77843_MUIC_ADC_RESERVED_ACC_2:
-	case MAX77843_MUIC_ADC_RESERVED_ACC_3:
-	case MAX77843_MUIC_ADC_RESERVED_ACC_4:
-	case MAX77843_MUIC_ADC_RESERVED_ACC_5:
 	case MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2:
 	case MAX77843_MUIC_ADC_PHONE_POWERED_DEV:
 	case MAX77843_MUIC_ADC_TTY_CONVERTER:
-- 
2.11.0

  parent reply	other threads:[~2017-03-29 11:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170329115509epcas5p1414c3cf20f3c8dd08e55c572540bd034@epcas5p1.samsung.com>
2017-03-29 11:54 ` [PATCH 0/2] Add support for USB accessories in the max77843 extcon driver Andi Shyti
     [not found]   ` <CGME20170329115509epcas5p14fddb50b71177529674457026a743c61@epcas5p1.samsung.com>
2017-03-29 11:54     ` [PATCH 1/2] extcon: max77843: improve the code and minimize duplicated lines Andi Shyti
     [not found]   ` <CGME20170329115509epcas5p16e5dd395695d94a294a91da6f113e5fe@epcas5p1.samsung.com>
2017-03-29 11:54     ` Andi Shyti [this message]
2017-03-29 14:27       ` [PATCH 2/2] extcon: max77843: support USB accessories as external USB hosts Krzysztof Kozlowski
2017-03-29 14:50         ` Andi Shyti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170329115453.4268-3-andi.shyti@samsung.com \
    --to=andi.shyti@samsung.com \
    --cc=andi@etezian.org \
    --cc=cw00.choi@samsung.com \
    --cc=jaewon02.kim@samsung.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.