Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4817080pxb; Mon, 15 Feb 2021 01:52:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqvpSuuu3R+EChTaU0RhBEmFUNXVijFrmY4WF14fMh+dAWVyJ5y7euP4yRAbAr8GRrjyGy X-Received: by 2002:a17:906:ada:: with SMTP id z26mr14619710ejf.218.1613382765906; Mon, 15 Feb 2021 01:52:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613382765; cv=none; d=google.com; s=arc-20160816; b=CYPE/Ji428FcjhZmaKBwnIXnjy5RAiQQD+G9NBK92DPY12H8wPLA6Ntg2cIjhG8xq3 TtT/+89mfoIkvRdGKY+Qssy85hiXoA9xgCkGl9HujJb3+cXFRbg6Ya8Aw7WtJMGQuMXN RRpGhtZTCMt4ibU8ac7e7XiAYv4sPQgLlJR0KXwUGd8kX2VDF7Ep66Z6dKDx7z8tqC79 r/qreEzCHb/dUOP7pR4x+ZImGgk7ecRYdIRIbeGVFqPmv/jw705d2066hSPeEVwN0ESJ d9EujRIpWuJfXhou7DZElx5HlHizGjSgdiu5338EqmR0hK+7CIRaRTwedPqB04Aqa5U8 FI2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=/1AGqWOmRthD00yEu2KIzxHteZZXjPiXJ2yDr24vXlA=; b=A9F7S6HNU7hrCzQekQ7O7o7o7i1/krLlxipWm3IHPFs6WXGdOpjj4tC+rYGfcXuTfF z76sgFw1hOpDFo1Pb372jmoBrudj+f1Wc5Plp7awAu/+Pun+4H8BWIXu9681mZBE0lJj ZjuJAatlZEf52L8wW464mAaY/ZHSpVTwjHNoPx6tB+wDPCxqMpswc+lmPf+VIx563mOQ tqjeiUbI2OkWXGh5QqsF0oi6ls+5KzY45kIUjZBP9RKU2gE5iFY0xdKNPODpzVrkRp7Y 1gvswOBKF27p30m7mlajQjAwwJYcBVpUF53NQHc2wChbOIR4f8Anu9WWWb4HAp9zpgxt YJTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=WGO+6TY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l20si11408062ejn.375.2021.02.15.01.52.21; Mon, 15 Feb 2021 01:52:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=WGO+6TY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230389AbhBOJvE (ORCPT + 99 others); Mon, 15 Feb 2021 04:51:04 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:44084 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbhBOJui (ORCPT ); Mon, 15 Feb 2021 04:50:38 -0500 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20210215094955epoutp014509ee7965ef6bcd9c562d7024771c1a~j4uwccE5c1543415434epoutp01u for ; Mon, 15 Feb 2021 09:49:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20210215094955epoutp014509ee7965ef6bcd9c562d7024771c1a~j4uwccE5c1543415434epoutp01u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1613382595; bh=/1AGqWOmRthD00yEu2KIzxHteZZXjPiXJ2yDr24vXlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WGO+6TY1B9VRbaS52Z2vggC8YY5QGSwJi26t0T1aWjZYg0tvgGbnDsx401X5kzcgj dvB1Jox+Sze/jnNGT8YA9sILkHuhMeGnieFRyZ+7s1MDtRKVtE006v5DPASQdpZTTk eQr/GO8vBXbb1DP2zHgAV3Dn+PzH+6rgkiebIjBk= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20210215094954epcas1p4c17d7859531c2a5055a50a7c7c341710~j4uwJJY9N3153431534epcas1p4g; Mon, 15 Feb 2021 09:49:54 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.156]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4DfK8H5vV4z4x9Q9; Mon, 15 Feb 2021 09:49:51 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id B8.67.09577.FB34A206; Mon, 15 Feb 2021 18:49:51 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20210215094951epcas1p3a7532c112193cbc9c2f3aa37a30ece33~j4us4CBEx0184401844epcas1p3o; Mon, 15 Feb 2021 09:49:51 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210215094951epsmtrp2eaa536a603ce823b3c82a04becb89e25~j4us3WWJX2912229122epsmtrp2P; Mon, 15 Feb 2021 09:49:51 +0000 (GMT) X-AuditID: b6c32a39-bfdff70000002569-b9-602a43bf808c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 41.2E.13470.FB34A206; Mon, 15 Feb 2021 18:49:51 +0900 (KST) Received: from localhost.localdomain (unknown [10.113.221.102]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210215094951epsmtip264c395611c5666d929110a11d67b49d4~j4uso1QTG1775517755epsmtip2J; Mon, 15 Feb 2021 09:49:51 +0000 (GMT) From: Chanwoo Choi To: gregkh@linuxfoundation.org Cc: cw00.choi@samsung.com, chanwoo@kernel.org, myungjoo.ham@samsung.com, linux-kernel@vger.kernel.org, Nikita Travkin Subject: [PATCH 3/3] extcon: sm5502: Detect OTG when USB_ID is connected to ground Date: Mon, 15 Feb 2021 19:06:10 +0900 Message-Id: <20210215100610.19911-4-cw00.choi@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210215100610.19911-1-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJKsWRmVeSWpSXmKPExsWy7bCmvu5+Z60Eg6tNuhYTb1xhsbj+5Tmr RfPi9WwWl3fNYbO43biCzWLLtn9MDmweO2fdZffYtKqTzWP/3DXsHn1bVjF6fN4kF8AalW2T kZqYklqkkJqXnJ+SmZduq+QdHO8cb2pmYKhraGlhrqSQl5ibaqvk4hOg65aZA3SBkkJZYk4p UCggsbhYSd/Opii/tCRVISO/uMRWKbUgJafAskCvODG3uDQvXS85P9fK0MDAyBSoMCE7Y/au 04wF54UqDs+oa2CczN/FyMkhIWAicaetnbmLkYtDSGAHo8T2roPsEM4nRokLP6ZAZb4xSqxf /oMRpmXR0ndMEIm9jBLHdn2Hcr4wSjw4f4gVpIpNQEti/4sbbCC2iICcxJPbf8BGMQv0MUrc utPJDpIQFgiR+HyvE2wsi4CqxMSLK8DivAJWEhtuLmOGWCcvsXrDATCbU8BaYue8VkaQQRIC h9glft74yQJR5CLx9vRzVghbWOLV8S3sELaUxOd3e9kg7GqJlSePsEE0dzBKbNl/AarBWGL/ 0slAP3AAnacpsX6XPkRYUWLn77lgxzEL8Em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YDzEKMHBrCTCe1VCI0GINyWxsiq1KD++qDQntfgQozQHi5I474Wuk/FCAumJJanZqakF qUUwWSYOTqkGprKys9GdEl/r7E3EbO4a/jnIoHbhu6ni9iwfJ+Mil7C0fRd+VjJ3r0tr0Ku7 6CQoZ/vo+N2axJDakFuL/5pfkb24aJrvEWMBpyKdGHfJAzb2F+eqRj0tSDopWDjztBHjMglG f86fdxsfcX0t3PtRLbr3+5ZX4WsXpEhpbaio/vGvSbzj+9HfOlwPtvrcUry+ZfbMnbWdxdzq q7frPhPYsmXx9PjTYQdS/vgYtP1q8Xif8d7poEVq6+lTzY9/NB44fjq7tEzm7J1mc1/2xisr L+12O2Q4K+Dl8oVLvB7ub9ULjZnR3lv7sqHh7cUY8d95P3dfuPz1f/u3DW5ti/V0Z9/l0FT5 vfaU/aqgd/WB05VYijMSDbWYi4oTAbRNeKKkAgAA X-CMS-MailID: 20210215094951epcas1p3a7532c112193cbc9c2f3aa37a30ece33 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210215094951epcas1p3a7532c112193cbc9c2f3aa37a30ece33 References: <20210215100610.19911-1-cw00.choi@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikita Travkin In it's curent state this driver ignores OTG adapters with ID pin connected to ground. This commit adds a check to set extcon into host mode when such OTG adapter is connected. Signed-off-by: Nikita Travkin Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-sm5502.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c index 106d4da647bd..db41d1c58efd 100644 --- a/drivers/extcon/extcon-sm5502.c +++ b/drivers/extcon/extcon-sm5502.c @@ -144,6 +144,7 @@ enum sm5502_muic_acc_type { SM5502_MUIC_ADC_AUDIO_TYPE1_FULL_REMOTE = 0x3e, /* | 001|11110| */ SM5502_MUIC_ADC_AUDIO_TYPE1_SEND_END = 0x5e, /* | 010|11110| */ /* |Dev Type1|--ADC| */ + SM5502_MUIC_ADC_GROUND_USB_OTG = 0x80, /* | 100|00000| */ SM5502_MUIC_ADC_OPEN_USB = 0x5f, /* | 010|11111| */ SM5502_MUIC_ADC_OPEN_TA = 0xdf, /* | 110|11111| */ SM5502_MUIC_ADC_OPEN_USB_OTG = 0xff, /* | 111|11111| */ @@ -291,11 +292,27 @@ static unsigned int sm5502_muic_get_cable_type(struct sm5502_muic_info *info) * connected with to MUIC device. */ cable_type = adc & SM5502_REG_ADC_MASK; - if (cable_type == SM5502_MUIC_ADC_GROUND) - return SM5502_MUIC_ADC_GROUND; switch (cable_type) { case SM5502_MUIC_ADC_GROUND: + ret = regmap_read(info->regmap, SM5502_REG_DEV_TYPE1, + &dev_type1); + if (ret) { + dev_err(info->dev, "failed to read DEV_TYPE1 reg\n"); + return ret; + } + + switch (dev_type1) { + case SM5502_REG_DEV_TYPE1_USB_OTG_MASK: + cable_type = SM5502_MUIC_ADC_GROUND_USB_OTG; + break; + default: + dev_dbg(info->dev, + "cannot identify the cable type: adc(0x%x), dev_type1(0x%x)\n", + adc, dev_type1); + return -EINVAL; + } + break; case SM5502_MUIC_ADC_SEND_END_BUTTON: case SM5502_MUIC_ADC_REMOTE_S1_BUTTON: case SM5502_MUIC_ADC_REMOTE_S2_BUTTON: @@ -396,6 +413,7 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info, con_sw = DM_DP_SWITCH_OPEN; vbus_sw = VBUSIN_SWITCH_VBUSOUT; break; + case SM5502_MUIC_ADC_GROUND_USB_OTG: case SM5502_MUIC_ADC_OPEN_USB_OTG: id = EXTCON_USB_HOST; con_sw = DM_DP_SWITCH_USB; -- 2.17.1