From patchwork Wed Oct 18 09:28:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 116255 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5848271qgn; Wed, 18 Oct 2017 02:29:11 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBpH92amSxS/CquA4uPYkHXkTYnPjJjQnAJNNVfasyFerYafrc6GTeI9rEoT6m/irqYdWu3 X-Received: by 10.98.51.198 with SMTP id z189mr14299306pfz.198.1508318951168; Wed, 18 Oct 2017 02:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508318951; cv=none; d=google.com; s=arc-20160816; b=Y+luK8pkDqANDl4x5otQYDV8y1jnsrV3JyVouP0vv1RC5a/znBY4jNaaR0EIWXKMQV 7Q7stTvNpbye/wZ1btMM66DY7G/8je0K4PZWyktQjCOdRaa6b/ZEH+6VtcBLXVNGhr2G xkML7gcu13wOctRzb275izXCstidtNvn9n/0TLzb/bQsBeV3DzygLdLfdNIY+nql1bTr rr9hpboY7qMAcgLMNYoXnPqh08QCLLwxKHzqwtdJD0CnITSGf7dFeFZ+cd6/553/qOb9 MUeUyKtaiGipzttf3OOjKNn1X/Z4ehNOuR/4TIDn5TU6/6rb/2ZXhZ22gQafhnriS9dN XO8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=4r8VHQCaxHLgKbbNf1S6fuDce0efaCplkFYCEw+wvt4=; b=t+YYPWq4uPhgdSoBl7T52rl/YTkH6L9TeE3a9MXEAvm9wMsziOF2N1/nt7WEOAeJbU kT0WW6bs5vdowCyUskqnIiROcLof6jB8IhlDzI1GyG9AlbjQvAHKypC8IwkK+0ZeOvDy VC2+n8na0XeYJOd/6n1RioXSrfW7o55WvV1wuKgsZaqM2YRCVM1c6KX1lzOi6yIwEA2R rAy6DTpG/eV74ZQ3ZccOEol4MNJr32k2VXkuBv7qKJdtAWD3JbHgVg/era7TZf9PuxN7 IJdg876w607n72ee2pZPmlwatp9AezngCAaffoqzO0XkcjnILae3OMYLAMp2aai+VIKn euSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t25si7134608pfj.353.2017.10.18.02.29.10; Wed, 18 Oct 2017 02:29:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967207AbdJRJ3D (ORCPT + 4 others); Wed, 18 Oct 2017 05:29:03 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:40481 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965409AbdJRJ2M (ORCPT ); Wed, 18 Oct 2017 05:28:12 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171018092809euoutp01dce2ca4a3ccbf37c8d89c441564339fe~uoAnkTuUo0476804768euoutp01-; Wed, 18 Oct 2017 09:28:09 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171018092808eucas1p2145a77cb6899de2869afc9576255d447~uoAm5lgm63032830328eucas1p2V; Wed, 18 Oct 2017 09:28:08 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 7F.0C.12867.8AE17E95; Wed, 18 Oct 2017 10:28:08 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171018092808eucas1p28a1a35b47d26687997798f68315d2a1f~uoAmMbpYA2603726037eucas1p2l; Wed, 18 Oct 2017 09:28:08 +0000 (GMT) X-AuditID: cbfec7f2-f793b6d000003243-95-59e71ea8235d Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 72.72.20118.8AE17E95; Wed, 18 Oct 2017 10:28:08 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OY000B2EIASYJ70@eusync4.samsung.com>; Wed, 18 Oct 2017 10:28:08 +0100 (BST) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , MyungJoo Ham , Chanwoo Choi , Lee Jones , Bartlomiej Zolnierkiewicz Subject: [PATCH 1/2] extcon: max88743: Add OTG power control to the MUIC driver Date: Wed, 18 Oct 2017 11:28:01 +0200 Message-id: <20171018092802.25390-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.14.2 In-reply-to: <20171018092802.25390-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRmVeSWpSXmKPExsWy7djPc7or5J5HGlw6qmyxccZ6VovrX56z Wtz/epTR4vKuOWwWM87vY7JYe+Quu8XtxhVsDuwed67tYfPo27KK0ePzJrkA5igum5TUnMyy 1CJ9uwSujL6eZ6wFC0UreidXNDD+F+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KJJa WpybnltspFecmFtcmpeul5yfu4kRGD7bjv3csoOx613wIUYBDkYlHt4AlWeRQqyJZcWVuYcY JTiYlUR4mT8ChXhTEiurUovy44tKc1KLDzFKc7AoifP27lkdKSSQnliSmp2aWpBaBJNl4uCU amDM5r9tWP7K5ciE1HfJCyNOL4iefDFRQD9I8tMiHael04webz4tM3/e+ivJ20/9LYmRSJo8 9cvBb04TJ966475p0ooNL16sFLaewOgZNYfpTFAzi23Cb3unx/Z6miudU44HHUj2NhS9KT1D 9NexEsM2nXNP2K8sOP7rnpKg64T2/7Of7Nq7NvaPqBJLcUaioRZzUXEiAFuVCr4bAgAA X-CMS-MailID: 20171018092808eucas1p28a1a35b47d26687997798f68315d2a1f X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-CMS-RootMailID: 20171018092808eucas1p28a1a35b47d26687997798f68315d2a1f X-RootMTR: 20171018092808eucas1p28a1a35b47d26687997798f68315d2a1f References: <20171018092802.25390-1-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Enabling power on VBUS micro-usb pin is required only when passive OTG cable is connected. Initially OTG VBUS power control was planned to be done in charger driver. However such information is not really available from the extcon notifications, so VBUS power control has to be done directly in MUIC driver, which has all information about the attached accessory. For example SmartDock is externally powered accessory, provides OTG (USB HOST) functionality and use VBUS pin for charging a device battery, so the VBUS charging pump should be disabled in such case. Signed-off-by: Marek Szyprowski --- drivers/extcon/extcon-max77843.c | 16 ++++++++++++++++ include/linux/mfd/max77843-private.h | 3 +++ 2 files changed, 19 insertions(+) -- 2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Chanwoo Choi diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c index 6e722d552cf1..217c743405f8 100644 --- a/drivers/extcon/extcon-max77843.c +++ b/drivers/extcon/extcon-max77843.c @@ -240,6 +240,21 @@ static int max77843_muic_set_path(struct max77843_muic_info *info, return 0; } +static void max77843_charger_set_otg_vbus(struct max77843_muic_info *info, + bool on) +{ + struct max77693_dev *max77843 = info->max77843; + unsigned int cnfg00; + + if (on) + cnfg00 = MAX77843_CHG_OTG_MASK | MAX77843_CHG_BOOST_MASK; + else + cnfg00 = MAX77843_CHG_ENABLE | MAX77843_CHG_BUCK_MASK; + + regmap_update_bits(max77843->regmap_chg, MAX77843_CHG_REG_CHG_CNFG_00, + MAX77843_CHG_MODE_MASK, cnfg00); +} + static int max77843_muic_get_cable_type(struct max77843_muic_info *info, enum max77843_muic_cable_group group, bool *attached) { @@ -355,6 +370,7 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info) return ret; extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); + max77843_charger_set_otg_vbus(info, attached); break; case MAX77843_MUIC_GND_MHL_VB: case MAX77843_MUIC_GND_MHL: diff --git a/include/linux/mfd/max77843-private.h b/include/linux/mfd/max77843-private.h index c19303b0ccfd..0223cd5941c8 100644 --- a/include/linux/mfd/max77843-private.h +++ b/include/linux/mfd/max77843-private.h @@ -245,10 +245,13 @@ enum max77843_irq_muic { #define MAX77843_CHG_OVER_CURRENT_BAT (0x06 << 4) /* MAX77843 CHG_CNFG_00 register */ +#define MAX77843_CHG_MODE_MASK 0x0f #define MAX77843_CHG_DISABLE 0x00 #define MAX77843_CHG_ENABLE 0x05 #define MAX77843_CHG_MASK 0x01 +#define MAX77843_CHG_OTG_MASK 0x02 #define MAX77843_CHG_BUCK_MASK 0x04 +#define MAX77843_CHG_BOOST_MASK 0x08 /* MAX77843 CHG_CNFG_01 register */ #define MAX77843_CHG_RESTART_THRESHOLD_100 0x00 From patchwork Wed Oct 18 09:28:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 116254 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5848199qgn; Wed, 18 Oct 2017 02:29:04 -0700 (PDT) X-Google-Smtp-Source: ABhQp+StkUhJnWab20HUXk7zEuToskOCALNd+jBprKRrqigg0bYrm7Nz1wfVa58nwoPYBmd2xA2N X-Received: by 10.84.202.194 with SMTP id q2mr6822828plh.19.1508318944752; Wed, 18 Oct 2017 02:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508318944; cv=none; d=google.com; s=arc-20160816; b=nLGyt0NpSjnbnuzpgvuyUgV9GKo90CZwZ9g0ePJrmcxDh3eyBPw8iqV6oQaTUPxXjU 4+PWXXo2dsFGs7+weSJ+Wd+/8vFP/3lSMQs+tzXYOg3NcxCliV3d244zvF34PDPbPpEP fZ2IPw6Q6mQXXgD4m31b0yxZPN6dOi9dxL3/GkJ3I9vkT92aai25+kZ1CYfN5rWkac+X 0OD3Z3rwAs2NE/8GegnDof6jEi2wOQAdweIo7VfNFQIGlnLW0nAMDKywqsX2SoOZRqIv P1IrReZb2zNqp4GvRqSFrxpti0wsve/bwUgyERt1erUljxNQUU+WzHcKuzz8m3YAQFJX /PXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=pyZFzLFb4a02lA1wOf7qERb/cWC5gfHxDtion05Ij68=; b=DldXTVcmwc1CtnVXCGt2EOmmNtI3gH1TOL+16neUTZJOAtJ8kJWRZoMAYgTGrgbhcK X3jwle0Idggv5KkVnXNwAxfJNnsHL2bJVg4kQw3Zz9gE4kcbZmZifSaUmkg6VDlguNKd bRJHOQaTA+7fd+DVeT85B6UhKSANdOLPgKSWcWR3hjnX14lDFUE0uTKg9fSTgP00BQo8 fAUGnu8bsevWHI6vNdctgKc9KVT8++aggIhiT/5fVofSb4/9v/cdYLpW+xwfyahVqNPe fvxkTbxLydkbNspFFRoDP4paq7meT8tPxVb6AtfNHX6dsC9kvx42NrK6lJBFGnwT1YGO XKDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t25si7134608pfj.353.2017.10.18.02.29.04; Wed, 18 Oct 2017 02:29:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967205AbdJRJ3A (ORCPT + 4 others); Wed, 18 Oct 2017 05:29:00 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:60535 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967179AbdJRJ2M (ORCPT ); Wed, 18 Oct 2017 05:28:12 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171018092809euoutp02f1fa6e2ffe09b9d78e550dfd574e3a8b~uoAn6Uj0W3113231132euoutp02p; Wed, 18 Oct 2017 09:28:09 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171018092809eucas1p2f992c1bc191bef0bffdf7ec88cc48d6e~uoAnR2DN52603726037eucas1p2m; Wed, 18 Oct 2017 09:28:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id D7.B1.12907.8AE17E95; Wed, 18 Oct 2017 10:28:08 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171018092808eucas1p1752a01e42342115ff15ce76cf3a8ec1d~uoAmiZksj2064520645eucas1p1j; Wed, 18 Oct 2017 09:28:08 +0000 (GMT) X-AuditID: cbfec7f1-f793a6d00000326b-27-59e71ea86c05 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F5.3F.18832.8AE17E95; Wed, 18 Oct 2017 10:28:08 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OY000B2EIASYJ70@eusync4.samsung.com>; Wed, 18 Oct 2017 10:28:08 +0100 (BST) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , MyungJoo Ham , Chanwoo Choi , Lee Jones , Bartlomiej Zolnierkiewicz Subject: [PATCH 2/2] extcon: max88743: Add support for SmartDock accessory Date: Wed, 18 Oct 2017 11:28:02 +0200 Message-id: <20171018092802.25390-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.14.2 In-reply-to: <20171018092802.25390-1-m.szyprowski@samsung.com> X-Brightmail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xcjJISFgIvHnbBMbhC0mceHeeiCbi0NIYAmjxO5t j5hBEkICTUwSLQvEQWw2AUOJrrddYA0iAs4Stz98YwFpYBa4wyjxvWkbI0hCWMBLomHnciCb g4NFQFVi5qxwkDCvgK3ErsvPGSGWyUu8X3AfzOYUsJM4vPsT1C5bica7jawTGHkXMDKsYhRJ LS3OTc8tNtQrTswtLs1L10vOz93ECAyfbcd+bt7BeGlj8CFGAQ5GJR7eAJVnkUKsiWXFlbmH GCU4mJVEeJk/AoV4UxIrq1KL8uOLSnNSiw8xSnOwKInz9u5ZHSkkkJ5YkpqdmlqQWgSTZeLg lGpg7Jc5Zqfy/Y6MYPjipcUmy5iZzP6HTX2b/NN1mmbThJJD0dMPMF/+/659x8SOaqP1r7Mi TqyvcD623WPS5/S/QfpPPvcwTanl1prs78QmUyn7NcP81ZQ0zmTbXuFJzNN3s9ys59EMS29M CpK61rB7T8nUXZFJITdFj8T1KK16uogxliN7wcU5SizFGYmGWsxFxYkAL8JxGxsCAAA= X-CMS-MailID: 20171018092808eucas1p1752a01e42342115ff15ce76cf3a8ec1d X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-CMS-RootMailID: 20171018092808eucas1p1752a01e42342115ff15ce76cf3a8ec1d X-RootMTR: 20171018092808eucas1p1752a01e42342115ff15ce76cf3a8ec1d References: <20171018092802.25390-1-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org SmartDock uses ADC_RESERVED_ACC_3 (0x10) ADC ID type and provides following features: 1. USB host with embedded USB hub (2-4 ports) for mice, keyboard, etc, 2. MHL for video output, 3. charging. Tested with Unitek Y-2165 MHL+OTG Hub Smart Phone Dock. Signed-off-by: Marek Szyprowski --- drivers/extcon/extcon-max77843.c | 77 +++++++++++++++++++++++++++++------- include/linux/mfd/max77843-private.h | 2 + 2 files changed, 65 insertions(+), 14 deletions(-) -- 2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Chanwoo Choi diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c index 217c743405f8..cc28d2622ae7 100644 --- a/drivers/extcon/extcon-max77843.c +++ b/drivers/extcon/extcon-max77843.c @@ -80,7 +80,7 @@ enum max77843_muic_accessory_type { MAX77843_MUIC_ADC_REMOTE_S12_BUTTON, MAX77843_MUIC_ADC_RESERVED_ACC_1, MAX77843_MUIC_ADC_RESERVED_ACC_2, - MAX77843_MUIC_ADC_RESERVED_ACC_3, + MAX77843_MUIC_ADC_RESERVED_ACC_3, /* SmartDock */ MAX77843_MUIC_ADC_RESERVED_ACC_4, MAX77843_MUIC_ADC_RESERVED_ACC_5, MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2, @@ -119,6 +119,7 @@ enum max77843_muic_charger_type { MAX77843_MUIC_CHG_SPECIAL_BIAS, MAX77843_MUIC_CHG_RESERVED, MAX77843_MUIC_CHG_GND, + MAX77843_MUIC_CHG_DOCK, }; static const unsigned int max77843_extcon_cable[] = { @@ -130,6 +131,7 @@ static const unsigned int max77843_extcon_cable[] = { EXTCON_CHG_USB_FAST, EXTCON_CHG_USB_SLOW, EXTCON_DISP_MHL, + EXTCON_DOCK, EXTCON_JIG, EXTCON_NONE, }; @@ -200,7 +202,7 @@ static const struct regmap_irq_chip max77843_muic_irq_chip = { }; static int max77843_muic_set_path(struct max77843_muic_info *info, - u8 val, bool attached) + u8 val, bool attached, bool nobccomp) { struct max77693_dev *max77843 = info->max77843; int ret = 0; @@ -210,10 +212,16 @@ static int max77843_muic_set_path(struct max77843_muic_info *info, ctrl1 = val; else ctrl1 = MAX77843_MUIC_CONTROL1_SW_OPEN; + if (nobccomp) { + /* Disable BC1.2 protocol and force manual switch control */ + ctrl1 |= MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK; + } ret = regmap_update_bits(max77843->regmap_muic, MAX77843_MUIC_REG_CONTROL1, - MAX77843_MUIC_CONTROL1_COM_SW, ctrl1); + MAX77843_MUIC_CONTROL1_COM_SW | + MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK, + ctrl1); if (ret < 0) { dev_err(info->dev, "Cannot switch MUIC port\n"); return ret; @@ -303,6 +311,19 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info, break; } + if (adc == MAX77843_MUIC_ADC_RESERVED_ACC_3) { /* SmartDock */ + if (chg_type == MAX77843_MUIC_CHG_NONE) { + *attached = false; + cable_type = info->prev_chg_type; + info->prev_chg_type = MAX77843_MUIC_CHG_NONE; + } else { + *attached = true; + cable_type = MAX77843_MUIC_CHG_DOCK; + info->prev_chg_type = MAX77843_MUIC_CHG_DOCK; + } + break; + } + if (chg_type == MAX77843_MUIC_CHG_NONE) { *attached = false; cable_type = info->prev_chg_type; @@ -365,7 +386,7 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info) case MAX77843_MUIC_GND_USB_HOST_VB: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_USB, - attached); + attached, false); if (ret < 0) return ret; @@ -376,7 +397,7 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info) case MAX77843_MUIC_GND_MHL: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -412,7 +433,7 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info, return -EINVAL; } - ret = max77843_muic_set_path(info, path, attached); + ret = max77843_muic_set_path(info, path, attached, false); if (ret < 0) return ret; @@ -421,6 +442,26 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info, return 0; } +static int max77843_muic_dock_handler(struct max77843_muic_info *info, + bool attached) +{ + int ret; + + dev_dbg(info->dev, "external connector is %s (adc: 0x10)\n", + attached ? "attached" : "detached"); + + ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_USB, + attached, attached); + if (ret < 0) + return ret; + + extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached); + extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); + extcon_set_state_sync(info->edev, EXTCON_DOCK, attached); + + return 0; +} + static int max77843_muic_adc_handler(struct max77843_muic_info *info) { int ret, cable_type; @@ -435,6 +476,11 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info) info->prev_cable_type); switch (cable_type) { + case MAX77843_MUIC_ADC_RESERVED_ACC_3: /* SmartDock */ + ret = max77843_muic_dock_handler(info, attached); + if (ret < 0) + return ret; + break; case MAX77843_MUIC_ADC_GROUND: ret = max77843_muic_adc_gnd_handler(info); if (ret < 0) @@ -462,7 +508,6 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info) 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: @@ -506,7 +551,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_USB: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_USB, - attached); + attached, false); if (ret < 0) return ret; @@ -517,7 +562,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_DOWNSTREAM: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -527,7 +572,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_DEDICATED: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -537,7 +582,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_SPECIAL_500MA: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -547,7 +592,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_SPECIAL_1A: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -566,6 +611,9 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, false); break; + case MAX77843_MUIC_CHG_DOCK: + extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, attached); + break; case MAX77843_MUIC_CHG_NONE: break; default: @@ -574,7 +622,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) attached ? "attached" : "detached", chg_type); max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); return -EINVAL; } @@ -814,7 +862,8 @@ static int max77843_muic_probe(struct platform_device *pdev) max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS); /* Set initial path for UART */ - max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true); + max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true, + false); /* Check revision number of MUIC device */ ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id); diff --git a/include/linux/mfd/max77843-private.h b/include/linux/mfd/max77843-private.h index 0223cd5941c8..b8908bf8d315 100644 --- a/include/linux/mfd/max77843-private.h +++ b/include/linux/mfd/max77843-private.h @@ -350,6 +350,7 @@ enum max77843_irq_muic { /* MAX77843 CONTROL register */ #define MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT 0 #define MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT 3 +#define MAX77843_MUIC_CONTROL1_NOBCCOMP_SHIFT 6 #define MAX77843_MUIC_CONTROL1_IDBEN_SHIFT 7 #define MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT 0 #define MAX77843_MUIC_CONTROL2_ADCEN_SHIFT 1 @@ -366,6 +367,7 @@ enum max77843_irq_muic { #define MAX77843_MUIC_CONTROL1_COMP1SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT) #define MAX77843_MUIC_CONTROL1_COMP2SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT) #define MAX77843_MUIC_CONTROL1_IDBEN_MASK BIT(MAX77843_MUIC_CONTROL1_IDBEN_SHIFT) +#define MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK BIT(MAX77843_MUIC_CONTROL1_NOBCCOMP_SHIFT) #define MAX77843_MUIC_CONTROL2_LOWPWR_MASK BIT(MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT) #define MAX77843_MUIC_CONTROL2_ADCEN_MASK BIT(MAX77843_MUIC_CONTROL2_ADCEN_SHIFT) #define MAX77843_MUIC_CONTROL2_CPEN_MASK BIT(MAX77843_MUIC_CONTROL2_CPEN_SHIFT)